[llvm-commits] CVS: llvm/tools/lto/Makefile lto.cpp

Chris Lattner sabre at nondot.org
Sat May 5 21:50:13 PDT 2007



Changes in directory llvm/tools/lto:

Makefile updated: 1.8 -> 1.9
lto.cpp updated: 1.38 -> 1.39
---
Log message:

bitcodify


---
Diffs of the changes:  (+24 -7)

 Makefile |    2 +-
 lto.cpp  |   29 +++++++++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)


Index: llvm/tools/lto/Makefile
diff -u llvm/tools/lto/Makefile:1.8 llvm/tools/lto/Makefile:1.9
--- llvm/tools/lto/Makefile:1.8	Wed Jan 31 19:18:57 2007
+++ llvm/tools/lto/Makefile	Sat May  5 23:49:55 2007
@@ -24,7 +24,7 @@
   BUILD_ARCHIVE = 1
 endif
 
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter bitreader bitwriter
 
 include $(LEVEL)/Makefile.common
 


Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.38 llvm/tools/lto/lto.cpp:1.39
--- llvm/tools/lto/lto.cpp:1.38	Tue Mar  6 22:41:30 2007
+++ llvm/tools/lto/lto.cpp	Sat May  5 23:49:55 2007
@@ -17,12 +17,14 @@
 #include "llvm/Linker.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.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"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/System/Program.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Analysis/Passes.h"
@@ -51,7 +53,7 @@
   return l;
 }
 
-
+static bool Bitcode = false;
 
 /// If symbol is not used then make it internal and let optimizer takes 
 /// care of it.
@@ -119,7 +121,14 @@
   NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
   if (pos != allModules.end())
     m = allModules[InputFilename.c_str()];
-  else {
+  else if (Bitcode) {
+    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;
   }
@@ -376,8 +385,12 @@
     std::string tempFileName(FinalOutputPath.c_str());
     tempFileName += "0.bc";
     std::ofstream Out(tempFileName.c_str(), io_mode);
-    OStream L(Out);
-    WriteBytecodeToFile(bigOne, L);
+    if (Bitcode) {
+      WriteBitcodeToFile(bigOne, Out);
+    } else {
+      OStream L(Out);
+      WriteBytecodeToFile(bigOne, L);
+    }
   }
 
   // Strip leading underscore because it was added to match names
@@ -430,8 +443,12 @@
     std::string tempFileName(FinalOutputPath.c_str());
     tempFileName += "1.bc";
     std::ofstream Out(tempFileName.c_str(), io_mode);
-    OStream L(Out);
-    WriteBytecodeToFile(bigOne, L);
+    if (Bitcode) {
+      WriteBitcodeToFile(bigOne, Out);
+    } else {
+      OStream L(Out);
+      WriteBytecodeToFile(bigOne, L);
+    }
   }
 
   targetTriple = bigOne->getTargetTriple();






More information about the llvm-commits mailing list