#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/System/Valgrind.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/Valgrind.h"
#include "llvm/LinkAllVMCore.h"
using namespace llvm;
-// AsChild - Specifies that this invocation of bugpoint is being generated
-// from a parent process. It is not intended to be used by users so the
-// option is hidden.
-static cl::opt<bool>
-AsChild("as-child", cl::desc("Run bugpoint as child process"),
- cl::ReallyHidden);
-
static cl::opt<bool>
FindBugs("find-bugs", cl::desc("Run many different optimization sequences "
"on program to find bugs"), cl::init(false));
AddToDriver(BugDriver &_D) : D(_D) {}
virtual void add(Pass *P) {
- const PassInfo *PI = P->getPassInfo();
- D.addPasses(&PI, &PI + 1);
+ const void *ID = P->getPassID();
+ const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
+ D.addPass(PI->getPassArgument());
}
};
}
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
+ // Initialize passes
+ PassRegistry &Registry = *PassRegistry::getPassRegistry();
+ initializeCore(Registry);
+ initializeScalarOpts(Registry);
+ initializeIPO(Registry);
+ initializeAnalysis(Registry);
+ initializeIPA(Registry);
+ initializeTransformUtils(Registry);
+ initializeInstCombine(Registry);
+ initializeInstrumentation(Registry);
+ initializeTarget(Registry);
+
cl::ParseCommandLineOptions(argc, argv,
"LLVM automatic testcase reducer. See\nhttp://"
"llvm.org/cmds/bugpoint.html"
// If we have an override, set it and then track the triple we want Modules
// to use.
if (!OverrideTriple.empty()) {
- TargetTriple.setTriple(OverrideTriple);
- outs() << "Override triple set to '" << OverrideTriple << "'\n";
+ TargetTriple.setTriple(Triple::normalize(OverrideTriple));
+ outs() << "Override triple set to '" << TargetTriple.getTriple() << "'\n";
}
if (MemoryLimit < 0) {
MemoryLimit = 100;
}
- BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit,
+ BugDriver D(argv[0], FindBugs, TimeoutValue, MemoryLimit,
UseValgrind, Context);
if (D.addSources(InputFilenames)) return 1;
/*RunInliner=*/true,
/*VerifyEach=*/false);
- D.addPasses(PassList.begin(), PassList.end());
+
+ for (std::vector<const PassInfo*>::iterator I = PassList.begin(),
+ E = PassList.end();
+ I != E; ++I) {
+ const PassInfo* PI = *I;
+ 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
sys::Process::PreventCoreFiles();
- try {
- return D.run();
- } catch (ToolExecutionError &TEE) {
- errs() << "Tool execution error: " << TEE.what() << '\n';
- } catch (const std::string& msg) {
- errs() << argv[0] << ": " << msg << "\n";
- } catch (const std::bad_alloc&) {
- errs() << "Oh no, a bugpoint process ran out of memory!\n"
- "To increase the allocation limits for bugpoint child\n"
- "processes, use the -mlimit option.\n";
- } catch (const std::exception &e) {
- errs() << "Whoops, a std::exception leaked out of bugpoint: "
- << e.what() << "\n"
- << "This is a bug in bugpoint!\n";
- } catch (...) {
- errs() << "Whoops, an exception leaked out of bugpoint. "
- << "This is a bug in bugpoint!\n";
+ std::string Error;
+ bool Failure = D.run(Error);
+ if (!Error.empty()) {
+ errs() << Error;
+ return 1;
}
- return 1;
+ return Failure;
}