diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index b2a8f030c5f..fe290805e4b 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -19,13 +19,14 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Assembly/Parser.h" +#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compressor.h" #include "llvm/Support/FileUtilities.h" +#include "llvm/Support/MemoryBuffer.h" #include #include - using namespace llvm; // Anonymous namespace to define command line options for debugging. @@ -77,6 +78,13 @@ Module *llvm::ParseInputFile(const std::string &InputFilename) { ParseError Err; Module *Result = ParseBytecodeFile(InputFilename, Compressor::decompressToNewBuffer); + if (!Result) { + std::auto_ptr Buffer( + MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size())); + if (Buffer.get()) + Result = ParseBitcodeFile(Buffer.get()); + } + if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) { std::cerr << "bugpoint: " << Err.getMessage() << "\n"; Result = 0; diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 55968399793..723134856dd 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -22,7 +22,6 @@ #include "llvm/PassManager.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Bytecode/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" diff --git a/tools/bugpoint/Makefile b/tools/bugpoint/Makefile index acafa838d0d..11741480dd5 100644 --- a/tools/bugpoint/Makefile +++ b/tools/bugpoint/Makefile @@ -11,7 +11,7 @@ LEVEL = ../.. TOOLNAME = bugpoint LINK_COMPONENTS := bcreader bcwriter asmparser instrumentation scalaropts ipo \ - linker + linker bitreader bitwriter REQUIRES_EH := 1 include $(LEVEL)/Makefile.common diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 210f348f354..e5435ed1bc0 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -24,6 +24,7 @@ #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/WriteBytecodePass.h" +#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/CommandLine.h" @@ -38,6 +39,9 @@ #include using namespace llvm; +static bool Bitcode = false; + + namespace { // ChildOutput - This option captures the name of the child output file that // is set up by the parent bugpoint process @@ -110,7 +114,10 @@ int BugDriver::runPassesAsChild(const std::vector &Passes) { // Write bytecode out to disk as the last step... OStream L(OutFile); - PM.add(new WriteBytecodePass(&L)); + if (Bitcode) + PM.add(CreateBitcodeWriterPass(OutFile)); + else + PM.add(new WriteBytecodePass(&L)); // Run all queued passes. PM.run(*Program);