From 1488670076908261af145778c23cb9aca30904e5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 20 Jul 2009 07:01:01 +0000 Subject: [PATCH] Add -std-{compile,link}-opts to bugpoint. - Sheesh. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76402 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/bugpoint.cpp | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 9aedd7e9e6b..df8fbc60046 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PluginLoader.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/StandardPasses.h" #include "llvm/System/Process.h" #include "llvm/System/Signals.h" #include "llvm/LinkAllVMCore.h" @@ -57,6 +58,14 @@ MemoryLimit("mlimit", cl::init(100), cl::value_desc("MBytes"), static cl::list PassList(cl::desc("Passes available:"), cl::ZeroOrMore); +static cl::opt +StandardCompileOpts("std-compile-opts", + cl::desc("Include the standard compile time optimizations")); + +static cl::opt +StandardLinkOpts("std-link-opts", + cl::desc("Include the standard link time optimizations")); + /// BugpointIsInterrupted - Set to true when the user presses ctrl-c. bool llvm::BugpointIsInterrupted = false; @@ -64,6 +73,20 @@ static void BugpointInterruptFunction() { BugpointIsInterrupted = true; } +// Hack to capture a pass list. +namespace { + class AddToDriver : public PassManager { + BugDriver &D; + public: + AddToDriver(BugDriver &_D) : D(_D) {} + + virtual void add(Pass *P) { + const PassInfo *PI = P->getPassInfo(); + D.addPasses(&PI, &PI + 1); + } + }; +} + int main(int argc, char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(); llvm::PrettyStackTraceProgram X(argc, argv); @@ -77,6 +100,23 @@ int main(int argc, char **argv) { LLVMContext& Context = getGlobalContext(); BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit, Context); if (D.addSources(InputFilenames)) return 1; + + AddToDriver PM(D); + if (StandardCompileOpts) { + createStandardModulePasses(&PM, 3, + /*OptimizeSize=*/ false, + /*UnitAtATime=*/ true, + /*UnrollLoops=*/ true, + /*SimplifyLibCalls=*/ true, + /*HaveExceptions=*/ true, + createFunctionInliningPass()); + } + + if (StandardLinkOpts) + createStandardLTOPasses(&PM, /*Internalize=*/false, + /*RunInliner=*/true, + /*VerifyEach=*/false); + D.addPasses(PassList.begin(), PassList.end()); // Bugpoint has the ability of generating a plethora of core files, so to