switch tools to bitcode from bytecode


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36872 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index fe29080..00dfc32 100644
--- a/tools/bugpoint/BugDriver.cpp
+++ b/tools/bugpoint/BugDriver.cpp
@@ -20,9 +20,7 @@
 #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>
@@ -75,16 +73,13 @@
 /// return it, or return null if not possible.
 ///
 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());
-  }
+  std::auto_ptr<MemoryBuffer> Buffer(
+       MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
+  Module *Result = 0;
+  if (Buffer.get())
+    Result = ParseBitcodeFile(Buffer.get());
   
+  ParseError Err;
   if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
     std::cerr << "bugpoint: " << Err.getMessage() << "\n"; 
     Result = 0;
diff --git a/tools/bugpoint/Makefile b/tools/bugpoint/Makefile
index 1174148..6d8d7a0 100644
--- a/tools/bugpoint/Makefile
+++ b/tools/bugpoint/Makefile
@@ -10,7 +10,7 @@
 
 TOOLNAME = bugpoint
 
-LINK_COMPONENTS := bcreader bcwriter asmparser instrumentation scalaropts ipo \
+LINK_COMPONENTS := asmparser instrumentation scalaropts ipo \
                    linker bitreader bitwriter
 REQUIRES_EH := 1
 
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index e5435ed..5f031dc 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -23,7 +23,6 @@
 #include "llvm/Module.h"
 #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"
@@ -39,8 +38,6 @@
 #include <fstream>
 using namespace llvm;
 
-static bool Bitcode = false;
-
 
 namespace {
   // ChildOutput - This option captures the name of the child output file that
@@ -59,12 +56,8 @@
                                std::ios::binary;
   std::ofstream Out(Filename.c_str(), io_mode);
   if (!Out.good()) return true;
-  try {
-    OStream L(Out);
-    WriteBytecodeToFile(M ? M : Program, L, /*compression=*/false);
-  } catch (...) {
-    return true;
-  }
+  
+  WriteBitcodeToFile(M, Out);
   return false;
 }
 
@@ -113,11 +106,7 @@
   PM.add(createVerifierPass());
 
   // Write bytecode out to disk as the last step...
-  OStream L(OutFile);
-  if (Bitcode)
-    PM.add(CreateBitcodeWriterPass(OutFile));
-  else
-    PM.add(new WriteBytecodePass(&L));
+  PM.add(CreateBitcodeWriterPass(OutFile));
 
   // Run all queued passes.
   PM.run(*Program);
@@ -161,8 +150,7 @@
     cerr << "Error opening bytecode file: " << inputFilename << "\n";
     return(1);
   }
-  OStream L(InFile);
-  WriteBytecodeToFile(Program,L,false);
+  WriteBitcodeToFile(Program, InFile);
   InFile.close();
 
   // setup the child process' arguments
diff --git a/tools/llc/Makefile b/tools/llc/Makefile
index fa7a1b4..aa767ae 100644
--- a/tools/llc/Makefile
+++ b/tools/llc/Makefile
@@ -15,7 +15,7 @@
 # early so we can set up LINK_COMPONENTS before including Makefile.rules
 include $(LEVEL)/Makefile.config
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) bcreader bitreader
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) bitreader
 
 include $(LLVM_SRC_ROOT)/Makefile.rules
 
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index d96d164..0522420 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -14,7 +14,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/FileWriters.h"
 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
 #include "llvm/Target/SubtargetFeature.h"
@@ -23,10 +22,10 @@
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
 #include "llvm/PassManager.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Compressor.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PluginLoader.h"
@@ -40,9 +39,6 @@
 #include <memory>
 using namespace llvm;
 
-cl::opt<bool> Bitcode("bitcode");
-
-
 // General options for llc.  Other pass-specific options are specified
 // within the corresponding llc passes, and target-specific options
 // and back-end code generation options are specified with the target machine.
@@ -183,17 +179,13 @@
   std::string ErrorMessage;
   std::auto_ptr<Module> M;
   
-  if (Bitcode) {
-    std::auto_ptr<MemoryBuffer> Buffer(
-        MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
-    if (Buffer.get())
-      M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
-    else
-      ErrorMessage = "Error reading file '" + InputFilename + "'";
-  } else {
-    M.reset(ParseBytecodeFile(InputFilename, 
-                              Compressor::decompressToNewBuffer,
-                              &ErrorMessage));
+  {
+  std::auto_ptr<MemoryBuffer> Buffer(
+       MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
+  if (Buffer.get())
+    M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
+  else
+    ErrorMessage = "Error reading file '" + InputFilename + "'";
   }
   if (M.get() == 0) {
     std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
diff --git a/tools/lli/Makefile b/tools/lli/Makefile
index f5383d3b..d443b15 100644
--- a/tools/lli/Makefile
+++ b/tools/lli/Makefile
@@ -9,7 +9,7 @@
 
 LEVEL    := ../..
 TOOLNAME := lli
-LINK_COMPONENTS := jit interpreter native bcreader bitreader selectiondag
+LINK_COMPONENTS := jit interpreter native bitreader selectiondag
 
 # Enable JIT support
 include $(LEVEL)/Makefile.common
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index e380953..a1caf11 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -17,13 +17,11 @@
 #include "llvm/ModuleProvider.h"
 #include "llvm/Type.h"
 #include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Compressor.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PluginLoader.h"
@@ -34,8 +32,6 @@
 using namespace llvm;
 
 namespace {
-  cl::opt<bool> Bitcode("bitcode");
-
   cl::opt<std::string>
   InputFile(cl::desc("<input bytecode>"), cl::Positional, cl::init("-"));
 
@@ -81,19 +77,13 @@
   // Load the bytecode...
   std::string ErrorMsg;
   ModuleProvider *MP = 0;
-  if (Bitcode) {
-    MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
-                                                        InputFile.size());
-    if (Buffer == 0)
-      ErrorMsg = "Error reading file '" + InputFile + "'";
-    else {
-      MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
-      if (!MP) delete Buffer;
-    }
-  } else {
-    MP = getBytecodeModuleProvider(InputFile, 
-                                   Compressor::decompressToNewBuffer,
-                                   &ErrorMsg);
+  MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
+                                                      InputFile.size());
+  if (Buffer == 0)
+    ErrorMsg = "Error reading file '" + InputFile + "'";
+  else {
+    MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
+    if (!MP) delete Buffer;
   }
   
   if (!MP) {
diff --git a/tools/lto/Makefile b/tools/lto/Makefile
index 6cb1a7b..1b349f7 100644
--- a/tools/lto/Makefile
+++ b/tools/lto/Makefile
@@ -24,7 +24,7 @@
   BUILD_ARCHIVE = 1
 endif
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter bitreader bitwriter
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bitreader bitwriter
 
 include $(LEVEL)/Makefile.common
 
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index f7ea310..3420cdf 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -17,9 +17,8 @@
 #include "llvm/Linker.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/ModuleProvider.h"
 #include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Bytecode/Reader.h"
-#include "llvm/Bytecode/Writer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/SystemUtils.h"
@@ -40,7 +39,6 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/LinkTimeOptimizer.h"
 #include <fstream>
 #include <ostream>
@@ -53,8 +51,6 @@
   return l;
 }
 
-static bool Bitcode = false;
-
 /// If symbol is not used then make it internal and let optimizer takes 
 /// care of it.
 void LLVMSymbol::mayBeNotUsed() { 
@@ -121,16 +117,13 @@
   NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
   if (pos != allModules.end())
     m = allModules[InputFilename.c_str()];
-  else if (Bitcode) {
+  else {
     if (MemoryBuffer *Buffer
         = MemoryBuffer::getFile(&InputFilename[0], InputFilename.size())) {
       m = ParseBitcodeFile(Buffer);
       delete Buffer;
     }
     allModules[InputFilename.c_str()] = m;
-  } else {
-    m = ParseBytecodeFile(InputFilename);
-    allModules[InputFilename.c_str()] = m;
   }
   return m;
 }
@@ -385,12 +378,7 @@
     std::string tempFileName(FinalOutputPath.c_str());
     tempFileName += "0.bc";
     std::ofstream Out(tempFileName.c_str(), io_mode);
-    if (Bitcode) {
-      WriteBitcodeToFile(bigOne, Out);
-    } else {
-      OStream L(Out);
-      WriteBytecodeToFile(bigOne, L);
-    }
+    WriteBitcodeToFile(bigOne, Out);
   }
 
   // Strip leading underscore because it was added to match names
@@ -443,12 +431,7 @@
     std::string tempFileName(FinalOutputPath.c_str());
     tempFileName += "1.bc";
     std::ofstream Out(tempFileName.c_str(), io_mode);
-    if (Bitcode) {
-      WriteBitcodeToFile(bigOne, Out);
-    } else {
-      OStream L(Out);
-      WriteBytecodeToFile(bigOne, L);
-    }
+    WriteBitcodeToFile(bigOne, Out);
   }
 
   targetTriple = bigOne->getTargetTriple();
diff --git a/tools/opt/Makefile b/tools/opt/Makefile
index 76cb5b1..f444fe3 100644
--- a/tools/opt/Makefile
+++ b/tools/opt/Makefile
@@ -10,6 +10,6 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation scalaropts ipo
+LINK_COMPONENTS := bitreader bitwriter instrumentation scalaropts ipo
 
 include $(LEVEL)/Makefile.common
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 218e5f0..99249b9 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -14,8 +14,6 @@
 
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Bytecode/Reader.h"
-#include "llvm/Bytecode/WriteBytecodePass.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Analysis/Verifier.h"
@@ -37,17 +35,12 @@
 #include <algorithm>
 using namespace llvm;
 
-static cl::opt<bool> Bitcode("bitcode");
-
 // The OptimizationList is automatically populated with registered Passes by the
 // PassNameParser.
 //
 static cl::list<const PassInfo*, bool, PassNameParser>
 PassList(cl::desc("Optimizations available:"));
 
-static cl::opt<bool> NoCompress("disable-compression", cl::init(true),
-       cl::desc("Don't compress the generated bytecode"));
-
 // Other command line options...
 //
 static cl::opt<std::string>
@@ -267,21 +260,15 @@
 
     // Load the input module...
     std::auto_ptr<Module> M;
-    if (Bitcode) {
-      MemoryBuffer *Buffer
-        = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
-      
-      if (Buffer == 0)
-        ErrorMessage = "Error reading file '" + InputFilename + "'";
-      else
-        M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
-      
-      delete Buffer;
-    } else {
-      M.reset(ParseBytecodeFile(InputFilename, 
-                                Compressor::decompressToNewBuffer,
-                                &ErrorMessage));
-    }
+    MemoryBuffer *Buffer
+      = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
+    
+    if (Buffer == 0)
+      ErrorMessage = "Error reading file '" + InputFilename + "'";
+    else
+      M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
+    
+    delete Buffer;
     if (M.get() == 0) {
       cerr << argv[0] << ": ";
       if (ErrorMessage.size())
@@ -372,13 +359,8 @@
       Passes.add(createVerifierPass());
 
     // Write bytecode out to disk or cout as the last step...
-    OStream L(*Out);
-    if (!NoOutput && !AnalyzeOnly) {
-      if (Bitcode)
-        Passes.add(CreateBitcodeWriterPass(*Out));
-      else
-        Passes.add(new WriteBytecodePass(&L, false, !NoCompress));
-    }
+    if (!NoOutput && !AnalyzeOnly)
+      Passes.add(CreateBitcodeWriterPass(*Out));
 
     // Now that we have all of the passes ready, run them.
     Passes.run(*M.get());