[llvm-commits] [126952] Switch llvm-gcc to bitcode instead of bytecode

clattner at apple.com clattner at apple.com
Sun May 6 02:34:56 PDT 2007


Revision: 126952
Author:   clattner
Date:     2007-05-06 02:34:56 -0700 (Sun, 06 May 2007)

Log Message:
-----------
Switch llvm-gcc to bitcode instead of bytecode

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/Makefile.in
    apple-local/branches/llvm/gcc/llvm-backend.cpp
    apple-local/branches/llvm/gcc/llvm-linker-hack.cpp

Modified: apple-local/branches/llvm/gcc/Makefile.in
===================================================================
--- apple-local/branches/llvm/gcc/Makefile.in	2007-05-05 21:40:50 UTC (rev 126951)
+++ apple-local/branches/llvm/gcc/Makefile.in	2007-05-06 09:34:56 UTC (rev 126952)
@@ -1074,8 +1074,8 @@
 endif
 
 # We use llvm-config to determine the libraries that we need to link in our
-# target, optimizations analyses and the bcwriter.
-LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bcwriter ipo bcreader
+# target, optimizations analyses and the bitwriter.
+LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bitwriter ipo bitreader
 LLVMLIBFILES := $(shell $(LLVMBINPATH)/llvm-config --libfiles $(LLVMCOMPONENTS))
 LLVMLDFLAGS := $(shell $(LLVMBINPATH)/llvm-config --ldflags)
 LIBS += $(LLVMLDFLAGS)

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-05-05 21:40:50 UTC (rev 126951)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-05-06 09:34:56 UTC (rev 126952)
@@ -29,12 +29,12 @@
 #include "llvm/ModuleProvider.h"
 #include "llvm/PassManager.h"
 #include "llvm/ValueSymbolTable.h"
+#include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Analysis/LoopPass.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bytecode/WriteBytecodePass.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
@@ -44,12 +44,12 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Transforms/Scalar.h"
-#include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include <cassert>
 #undef VISIBILITY_HIDDEN
 extern "C" {
@@ -190,7 +190,7 @@
 
 oFILEstream *AsmOutStream = 0;
 
-/// Read bytecode from PCH file. Initialize TheModue and setup
+/// Read bytecode from PCH file. Initialize TheModule and setup
 /// LTypes vector.
 void llvm_pch_read(const unsigned char *Buffer, unsigned Size) {
 
@@ -200,10 +200,13 @@
 
   clearTargetBuiltinCache();
 
+  MemoryBuffer *MB = MemoryBuffer::getNewMemBuffer(Size, ModuleName.c_str());
+  memcpy((char*)MB->getBufferStart(), Buffer, Size);
+
   std::string ErrMsg;
-  TheModule = ParseBytecodeBuffer(Buffer, Size, ModuleName,
-                                Compressor::decompressToNewBuffer,
-                                &ErrMsg);
+  TheModule = ParseBitcodeFile(MB, &ErrMsg);
+  delete MB;
+  
   if (!TheModule) {
     cerr << "Error reading bytecodes from PCH file\n";
     cerr << ErrMsg << "\n";
@@ -229,7 +232,7 @@
 
   // Emit an LLVM .bc file to the output.  This is used when passed
   // -emit-llvm -c to the GCC driver.
-  PerModulePasses->add(new WriteBytecodePass(AsmOutFile));
+  PerModulePasses->add(CreateBitcodeWriterPass(*AsmOutStream));
   
   // Disable emission of .ident into the output file... which is completely
   // wrong for llvm/.bc emission cases.
@@ -344,7 +347,7 @@
   if (emit_llvm_bc) {
     // Emit an LLVM .bc file to the output.  This is used when passed
     // -emit-llvm -c to the GCC driver.
-    PerModulePasses->add(new WriteBytecodePass(AsmOutFile));
+    PerModulePasses->add(CreateBitcodeWriterPass(*AsmOutStream));
 
     // Disable emission of .ident into the output file... which is completely
     // wrong for llvm/.bc emission cases.

Modified: apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-linker-hack.cpp	2007-05-05 21:40:50 UTC (rev 126951)
+++ apple-local/branches/llvm/gcc/llvm-linker-hack.cpp	2007-05-06 09:34:56 UTC (rev 126952)
@@ -25,8 +25,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Transforms/IPO.h"
-#include "llvm/Bytecode/Writer.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/Streams.h"
@@ -41,8 +40,8 @@
 void dummy_function() {
   new llvm::ExistingModuleProvider(0);
   llvm::createVerifierPass();
-  llvm::WriteBytecodeToFile(0, llvm::cout);
-  llvm::ParseBytecodeFile(NULL);
+  llvm::WriteBitcodeToFile(0, llvm::cout);
+  llvm::ParseBitcodeFile(NULL);
 
   llvm::createInstructionCombiningPass();
   llvm::createScalarReplAggregatesPass();





More information about the llvm-commits mailing list