diff options
author | Chris Lattner <sabre@nondot.org> | 2006-12-06 01:18:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-12-06 01:18:01 +0000 |
commit | c30598bc3ad792eb8cc75b188eb872a28c62ab71 (patch) | |
tree | 5636751bdd38ad434648958a350bfab3dd45a0fb /tools/llvmc | |
parent | bdbf5fd1c9cfa30a348596b127394fa1f4caf033 (diff) | |
download | external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.zip external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.tar.gz external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.tar.bz2 |
make all llvm tools call llvm_shutdown when they exit, static'ify some stuff.
With this change, I can now move -stats to print when llvm_shutdown is called.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc')
-rw-r--r-- | tools/llvmc/llvmc.cpp | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/tools/llvmc/llvmc.cpp b/tools/llvmc/llvmc.cpp index 3b22149..081ae45 100644 --- a/tools/llvmc/llvmc.cpp +++ b/tools/llvmc/llvmc.cpp @@ -17,17 +17,16 @@ #include "CompilerDriver.h" #include "Configuration.h" #include "llvm/Pass.h" -#include "llvm/System/Signals.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/System/Signals.h" #include <iostream> - using namespace llvm; -namespace { //===----------------------------------------------------------------------===// //=== PHASE OPTIONS //===----------------------------------------------------------------------===// -cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional, +static cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional, cl::desc("Choose final phase of compilation:"), cl::init(CompilerDriver::LINKING), cl::values( @@ -46,7 +45,7 @@ cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional, //===----------------------------------------------------------------------===// //=== OPTIMIZATION OPTIONS //===----------------------------------------------------------------------===// -cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore, +static cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore, cl::desc("Choose level of optimization to apply:"), cl::init(CompilerDriver::OPT_FAST_COMPILE), cl::values( @@ -70,48 +69,48 @@ cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore, //=== TOOL OPTIONS //===----------------------------------------------------------------------===// -cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore, +static cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore, cl::desc("Pass specific options to the pre-processor"), cl::value_desc("option")); -cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore, +static cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore, cl::desc("Alias for -Tpre"), cl::aliasopt(PreprocessorToolOpts)); -cl::list<std::string> TranslatorToolOpts("Ttrn", cl::ZeroOrMore, +static cl::list<std::string> TranslatorToolOpts("Ttrn", cl::ZeroOrMore, cl::desc("Pass specific options to the assembler"), cl::value_desc("option")); -cl::list<std::string> AssemblerToolOpts("Tasm", cl::ZeroOrMore, +static cl::list<std::string> AssemblerToolOpts("Tasm", cl::ZeroOrMore, cl::desc("Pass specific options to the assembler"), cl::value_desc("option")); -cl::alias AssemblerToolOptsAlias("Wa,", cl::ZeroOrMore, +static cl::alias AssemblerToolOptsAlias("Wa,", cl::ZeroOrMore, cl::desc("Alias for -Tasm"), cl::aliasopt(AssemblerToolOpts)); -cl::list<std::string> OptimizerToolOpts("Topt", cl::ZeroOrMore, +static cl::list<std::string> OptimizerToolOpts("Topt", cl::ZeroOrMore, cl::desc("Pass specific options to the optimizer"), cl::value_desc("option")); -cl::list<std::string> LinkerToolOpts("Tlnk", cl::ZeroOrMore, +static cl::list<std::string> LinkerToolOpts("Tlnk", cl::ZeroOrMore, cl::desc("Pass specific options to the linker"), cl::value_desc("option")); -cl::alias LinkerToolOptsAlias("Wl,", cl::ZeroOrMore, +static cl::alias LinkerToolOptsAlias("Wl,", cl::ZeroOrMore, cl::desc("Alias for -Tlnk"), cl::aliasopt(LinkerToolOpts)); -cl::list<std::string> fOpts("f", cl::ZeroOrMore, cl::Prefix, +static cl::list<std::string> fOpts("f", cl::ZeroOrMore, cl::Prefix, cl::desc("Pass through -f options to compiler tools"), cl::value_desc("option")); -cl::list<std::string> MOpts("M", cl::ZeroOrMore, cl::Prefix, +static cl::list<std::string> MOpts("M", cl::ZeroOrMore, cl::Prefix, cl::desc("Pass through -M options to compiler tools"), cl::value_desc("option")); -cl::list<std::string> WOpts("W", cl::ZeroOrMore, cl::Prefix, +static cl::list<std::string> WOpts("W", cl::ZeroOrMore, cl::Prefix, cl::desc("Pass through -W options to compiler tools"), cl::value_desc("option")); -cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix, +static cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix, cl::desc("Specify path to find llvmc sub-tools"), cl::value_desc("dir")); @@ -119,17 +118,17 @@ cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix, //=== INPUT OPTIONS //===----------------------------------------------------------------------===// -cl::list<std::string> LibPaths("L", cl::Prefix, +static cl::list<std::string> LibPaths("L", cl::Prefix, cl::desc("Specify a library search path"), cl::value_desc("dir")); -cl::list<std::string> Libraries("l", cl::Prefix, +static cl::list<std::string> Libraries("l", cl::Prefix, cl::desc("Specify base name of libraries to link to"), cl::value_desc("lib")); -cl::list<std::string> Includes("I", cl::Prefix, +static cl::list<std::string> Includes("I", cl::Prefix, cl::desc("Specify location to search for included source"), cl::value_desc("dir")); -cl::list<std::string> Defines("D", cl::Prefix, +static cl::list<std::string> Defines("D", cl::Prefix, cl::desc("Specify a pre-processor symbol to define"), cl::value_desc("symbol")); @@ -137,22 +136,22 @@ cl::list<std::string> Defines("D", cl::Prefix, //=== OUTPUT OPTIONS //===----------------------------------------------------------------------===// -cl::opt<std::string> OutputFilename("o", +static cl::opt<std::string> OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("file")); -cl::opt<std::string> OutputMachine("m", cl::Prefix, +static cl::opt<std::string> OutputMachine("m", cl::Prefix, cl::desc("Specify a target machine"), cl::value_desc("machine")); -cl::opt<bool> Native("native", cl::init(false), +static cl::opt<bool> Native("native", cl::init(false), cl::desc("Generative native code instead of bytecode")); -cl::opt<bool> DebugOutput("g", cl::init(false), +static cl::opt<bool> DebugOutput("g", cl::init(false), cl::desc("Generate objects that include debug symbols")); -cl::opt<bool> StripOutput("strip", cl::init(false), +static cl::opt<bool> StripOutput("strip", cl::init(false), cl::desc("Strip all symbols from linked output file")); -cl::opt<std::string> PrintFileName("print-fname", cl::Optional, +static cl::opt<std::string> PrintFileName("print-fname", cl::Optional, cl::value_desc("file"), cl::desc("Print the full path for the option's value")); @@ -160,28 +159,28 @@ cl::opt<std::string> PrintFileName("print-fname", cl::Optional, //=== INFORMATION OPTIONS //===----------------------------------------------------------------------===// -cl::opt<bool> DryRun("dry-run", cl::Optional, cl::init(false), +static cl::opt<bool> DryRun("dry-run", cl::Optional, cl::init(false), cl::desc("Do everything but perform the compilation actions")); -cl::alias DryRunAlias("y", cl::Optional, +static cl::alias DryRunAlias("y", cl::Optional, cl::desc("Alias for -dry-run"), cl::aliasopt(DryRun)); -cl::opt<bool> Verbose("verbose", cl::Optional, cl::init(false), +static cl::opt<bool> Verbose("verbose", cl::Optional, cl::init(false), cl::desc("Print out each action taken")); -cl::alias VerboseAlias("v", cl::Optional, +static cl::alias VerboseAlias("v", cl::Optional, cl::desc("Alias for -verbose"), cl::aliasopt(Verbose)); -cl::opt<bool> Debug("debug", cl::Optional, cl::init(false), +static cl::opt<bool> Debug("debug", cl::Optional, cl::init(false), cl::Hidden, cl::desc("Print out debugging information")); -cl::alias DebugAlias("d", cl::Optional, +static cl::alias DebugAlias("d", cl::Optional, cl::desc("Alias for -debug"), cl::aliasopt(Debug)); -cl::opt<bool> TimeActions("time-actions", cl::Optional, cl::init(false), +static cl::opt<bool> TimeActions("time-actions", cl::Optional, cl::init(false), cl::desc("Print execution time for each action taken")); -cl::opt<bool> ShowStats("stats", cl::Optional, cl::init(false), +static cl::opt<bool> ShowStats("stats", cl::Optional, cl::init(false), cl::desc("Print statistics accumulated during optimization")); //===----------------------------------------------------------------------===// @@ -215,7 +214,7 @@ static cl::list<std::string> Languages("x", cl::ZeroOrMore, //===----------------------------------------------------------------------===// //=== GetFileType - determine type of a file //===----------------------------------------------------------------------===// -const std::string GetFileType(const std::string& fname, unsigned pos) { +static const std::string GetFileType(const std::string& fname, unsigned pos) { static std::vector<std::string>::iterator langIt = Languages.begin(); static std::string CurrLang = ""; @@ -236,9 +235,7 @@ const std::string GetFileType(const std::string& fname, unsigned pos) { return fname.substr(fname.rfind('.', fname.size()) + 1); } -} // end anonymous namespace - -void handleTerminatingOptions(CompilerDriver* CD) { +static void handleTerminatingOptions(CompilerDriver* CD) { if (!PrintFileName.empty()) { sys::Path path = CD->GetPathForLinkageItem(PrintFileName, false); std::string p = path.toString(); @@ -252,6 +249,7 @@ void handleTerminatingOptions(CompilerDriver* CD) { /// @brief The main program for llvmc int main(int argc, char **argv) { + llvm_shutdown_obj X; // Call llvm_shutdown() on exit. // Make sure we print stack trace if we get bad signals sys::PrintStackTraceOnErrorSignal(); |