diff options
Diffstat (limited to 'llvm/tools/bugpoint/bugpoint.cpp')
-rw-r--r-- | llvm/tools/bugpoint/bugpoint.cpp | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp index 25c0e4176b2..fa4243fd057 100644 --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -30,84 +30,82 @@ #include "llvm/Transforms/IPO/AlwaysInliner.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" -//Enable this macro to debug bugpoint itself. +// Enable this macro to debug bugpoint itself. //#define DEBUG_BUGPOINT 1 using namespace llvm; static cl::opt<bool> -FindBugs("find-bugs", cl::desc("Run many different optimization sequences " - "on program to find bugs"), cl::init(false)); + FindBugs("find-bugs", cl::desc("Run many different optimization sequences " + "on program to find bugs"), + cl::init(false)); static cl::list<std::string> -InputFilenames(cl::Positional, cl::OneOrMore, - cl::desc("<input llvm ll/bc files>")); + InputFilenames(cl::Positional, cl::OneOrMore, + cl::desc("<input llvm ll/bc files>")); -static cl::opt<unsigned> -TimeoutValue("timeout", cl::init(300), cl::value_desc("seconds"), - cl::desc("Number of seconds program is allowed to run before it " - "is killed (default is 300s), 0 disables timeout")); +static cl::opt<unsigned> TimeoutValue( + "timeout", cl::init(300), cl::value_desc("seconds"), + cl::desc("Number of seconds program is allowed to run before it " + "is killed (default is 300s), 0 disables timeout")); static cl::opt<int> -MemoryLimit("mlimit", cl::init(-1), cl::value_desc("MBytes"), - cl::desc("Maximum amount of memory to use. 0 disables check." - " Defaults to 400MB (800MB under valgrind).")); + MemoryLimit("mlimit", cl::init(-1), cl::value_desc("MBytes"), + cl::desc("Maximum amount of memory to use. 0 disables check." + " Defaults to 400MB (800MB under valgrind).")); static cl::opt<bool> -UseValgrind("enable-valgrind", - cl::desc("Run optimizations through valgrind")); + UseValgrind("enable-valgrind", + cl::desc("Run optimizations through valgrind")); // The AnalysesList is automatically populated with registered Passes by the // PassNameParser. // -static cl::list<const PassInfo*, bool, PassNameParser> -PassList(cl::desc("Passes available:"), cl::ZeroOrMore); +static cl::list<const PassInfo *, bool, PassNameParser> + PassList(cl::desc("Passes available:"), cl::ZeroOrMore); static cl::opt<bool> -StandardLinkOpts("std-link-opts", - cl::desc("Include the standard link time optimizations")); + StandardLinkOpts("std-link-opts", + cl::desc("Include the standard link time optimizations")); static cl::opt<bool> -OptLevelO1("O1", - cl::desc("Optimization level 1. Identical to 'opt -O1'")); + OptLevelO1("O1", cl::desc("Optimization level 1. Identical to 'opt -O1'")); static cl::opt<bool> -OptLevelO2("O2", - cl::desc("Optimization level 2. Identical to 'opt -O2'")); + OptLevelO2("O2", cl::desc("Optimization level 2. Identical to 'opt -O2'")); -static cl::opt<bool> -OptLevelOs("Os", - cl::desc("Like -O2 with extra optimizations for size. Similar to clang -Os")); +static cl::opt<bool> OptLevelOs( + "Os", + cl::desc( + "Like -O2 with extra optimizations for size. Similar to clang -Os")); static cl::opt<bool> -OptLevelO3("O3", - cl::desc("Optimization level 3. Identical to 'opt -O3'")); + OptLevelO3("O3", cl::desc("Optimization level 3. Identical to 'opt -O3'")); static cl::opt<std::string> -OverrideTriple("mtriple", cl::desc("Override target triple for module")); + OverrideTriple("mtriple", cl::desc("Override target triple for module")); /// BugpointIsInterrupted - Set to true when the user presses ctrl-c. bool llvm::BugpointIsInterrupted = false; #ifndef DEBUG_BUGPOINT -static void BugpointInterruptFunction() { - BugpointIsInterrupted = true; -} +static void BugpointInterruptFunction() { BugpointIsInterrupted = true; } #endif // Hack to capture a pass list. namespace { - class AddToDriver : public legacy::FunctionPassManager { - BugDriver &D; - public: - AddToDriver(BugDriver &_D) : FunctionPassManager(nullptr), D(_D) {} - - void add(Pass *P) override { - const void *ID = P->getPassID(); - const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID); - D.addPass(PI->getPassArgument()); - } - }; +class AddToDriver : public legacy::FunctionPassManager { + BugDriver &D; + +public: + AddToDriver(BugDriver &_D) : FunctionPassManager(nullptr), D(_D) {} + + void add(Pass *P) override { + const void *ID = P->getPassID(); + const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID); + D.addPass(PI->getPassArgument()); + } +}; } #ifdef LINK_POLLY_INTO_TOOLS @@ -120,7 +118,7 @@ int main(int argc, char **argv) { #ifndef DEBUG_BUGPOINT llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); llvm::PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. #endif // Initialize passes @@ -165,9 +163,10 @@ int main(int argc, char **argv) { MemoryLimit = 400; } - BugDriver D(argv[0], FindBugs, TimeoutValue, MemoryLimit, - UseValgrind, Context); - if (D.addSources(InputFilenames)) return 1; + BugDriver D(argv[0], FindBugs, TimeoutValue, MemoryLimit, UseValgrind, + Context); + if (D.addSources(InputFilenames)) + return 1; AddToDriver PM(D); @@ -192,8 +191,8 @@ int main(int argc, char **argv) { for (const PassInfo *PI : PassList) D.addPass(PI->getPassArgument()); - // Bugpoint has the ability of generating a plethora of core files, so to - // avoid filling up the disk, we prevent it +// Bugpoint has the ability of generating a plethora of core files, so to +// avoid filling up the disk, we prevent it #ifndef DEBUG_BUGPOINT sys::Process::PreventCoreFiles(); #endif |