From 72621d11de5b873f1695f391eb95f0b336c3d2d4 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 4 Jul 2009 13:58:26 +0000 Subject: Import LLVM 74788. --- tools/bugpoint/BugDriver.cpp | 25 ++++++++++++++----------- tools/bugpoint/BugDriver.h | 9 +++++++-- tools/bugpoint/CrashDebugger.cpp | 2 +- tools/bugpoint/Miscompilation.cpp | 2 +- tools/bugpoint/OptimizerDriver.cpp | 2 +- tools/bugpoint/bugpoint.cpp | 6 ++++-- 6 files changed, 28 insertions(+), 18 deletions(-) (limited to 'tools/bugpoint') diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index d050b59..aab5072 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -64,25 +65,27 @@ std::string llvm::getPassesString(const std::vector &Passes) { } BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs, - unsigned timeout, unsigned memlimit) - : ToolName(toolname), ReferenceOutputFile(OutputFile), + unsigned timeout, unsigned memlimit, + LLVMContext& ctxt) + : Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile), Program(0), Interpreter(0), SafeInterpreter(0), gcc(0), - run_as_child(as_child), - run_find_bugs(find_bugs), Timeout(timeout), MemoryLimit(memlimit) {} + run_as_child(as_child), run_find_bugs(find_bugs), Timeout(timeout), + MemoryLimit(memlimit) {} /// ParseInputFile - Given a bitcode or assembly input filename, parse and /// return it, or return null if not possible. /// -Module *llvm::ParseInputFile(const std::string &Filename) { +Module *llvm::ParseInputFile(const std::string &Filename, + LLVMContext& Ctxt) { std::auto_ptr Buffer(MemoryBuffer::getFileOrSTDIN(Filename)); Module *Result = 0; if (Buffer.get()) - Result = ParseBitcodeFile(Buffer.get()); + Result = ParseBitcodeFile(Buffer.get(), Ctxt); - ParseError Err; - if (!Result && !(Result = ParseAssemblyFile(Filename, Err))) { - Err.PrintError("bugpoint", errs()); + SMDiagnostic Err; + if (!Result && !(Result = ParseAssemblyFile(Filename, Err, Ctxt))) { + Err.Print("bugpoint", errs()); Result = 0; } @@ -100,14 +103,14 @@ bool BugDriver::addSources(const std::vector &Filenames) { try { // Load the first input file. - Program = ParseInputFile(Filenames[0]); + Program = ParseInputFile(Filenames[0], Context); if (Program == 0) return true; if (!run_as_child) std::cout << "Read input file : '" << Filenames[0] << "'\n"; for (unsigned i = 1, e = Filenames.size(); i != e; ++i) { - std::auto_ptr M(ParseInputFile(Filenames[i])); + std::auto_ptr M(ParseInputFile(Filenames[i], Context)); if (M.get() == 0) return true; if (!run_as_child) diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index 96e9fb9..d637c24 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -30,6 +30,7 @@ class Function; class BasicBlock; class AbstractInterpreter; class Instruction; +class LLVMContext; class DebugCrashes; @@ -42,6 +43,7 @@ extern bool DisableSimplifyCFG; extern bool BugpointIsInterrupted; class BugDriver { + LLVMContext& Context; const std::string ToolName; // Name of bugpoint std::string ReferenceOutputFile; // Name of `good' output file Module *Program; // The raw program, linked together @@ -60,10 +62,12 @@ class BugDriver { public: BugDriver(const char *toolname, bool as_child, bool find_bugs, - unsigned timeout, unsigned memlimit); + unsigned timeout, unsigned memlimit, LLVMContext& ctxt); const std::string &getToolName() const { return ToolName; } + LLVMContext& getContext() { return Context; } + // Set up methods... these methods are used to copy information about the // command line arguments into instance variables of BugDriver. // @@ -290,7 +294,8 @@ private: /// ParseInputFile - Given a bitcode or assembly input filename, parse and /// return it, or return null if not possible. /// -Module *ParseInputFile(const std::string &InputFilename); +Module *ParseInputFile(const std::string &InputFilename, + LLVMContext& ctxt); /// getPassesString - Turn a list of passes into a string which indicates the diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 7daf57c..9697b34 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -73,7 +73,7 @@ ReducePassList::doTest(std::vector &Prefix, PrefixOutput.set(PfxOutput); OrigProgram = BD.Program; - BD.Program = ParseInputFile(PrefixOutput.toString()); + BD.Program = ParseInputFile(PrefixOutput.toString(), BD.getContext()); if (BD.Program == 0) { std::cerr << BD.getToolName() << ": Error reading bitcode file '" << PrefixOutput << "'!\n"; diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 7e8ff78..b3260e1 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -112,7 +112,7 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, // Ok, so now we know that the prefix passes work, try running the suffix // passes on the result of the prefix passes. // - Module *PrefixOutput = ParseInputFile(BitcodeResult); + Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext()); if (PrefixOutput == 0) { std::cerr << BD.getToolName() << ": Error reading bitcode file '" << BitcodeResult << "'!\n"; diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 3ded5e8..741be24 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -255,7 +255,7 @@ Module *BugDriver::runPassesOn(Module *M, // Restore the current program. swapProgramIn(OldProgram); - Module *Ret = ParseInputFile(BitcodeResult); + Module *Ret = ParseInputFile(BitcodeResult, Context); if (Ret == 0) { cerr << getToolName() << ": Error reading bitcode file '" << BitcodeResult << "'!\n"; diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 20f0e99..3365b22 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -16,6 +16,7 @@ #include "BugDriver.h" #include "ToolRunner.h" #include "llvm/LinkAllPasses.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/PassNameParser.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" @@ -73,8 +74,9 @@ int main(int argc, char **argv) { "llvm.org/cmds/bugpoint.html" " for more information.\n"); sys::SetInterruptFunction(BugpointInterruptFunction); - - BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit); + + LLVMContext Context; + BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit, Context); if (D.addSources(InputFilenames)) return 1; D.addPasses(PassList.begin(), PassList.end()); -- cgit v1.1