add bitcode support
authorChris Lattner <sabre@nondot.org>
Sun, 6 May 2007 05:47:06 +0000 (05:47 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 6 May 2007 05:47:06 +0000 (05:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36849 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.cpp
tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/Makefile
tools/bugpoint/OptimizerDriver.cpp

index b2a8f030c5f4ebb5f4a1296aaa16879e649ea816..fe290805e4b1a08c3b33bb65cc2c286418b3eb39 100644 (file)
 #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 <iostream>
 #include <memory>
-
 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<MemoryBuffer> 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;
index 559683997938cd0dd5df172ccac757ee7110c11e..723134856ddba9646676e5dcd2039262e5c1ebff 100644 (file)
@@ -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"
index acafa838d0d1bcd46bb0752fe7f9dbea43a9eeff..11741480dd5a6ba1d0ef3f8d1f77d322efca114c 100644 (file)
@@ -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
index 210f348f3546700a12e1e4e04356c71173abaf92..e5435ed1bc0cf0f232971ea142a136cfd4025873 100644 (file)
@@ -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 <fstream>
 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<const PassInfo*> &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);