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

Chris Lattner sabre at nondot.org
Sat May 5 22:51:55 PDT 2007



Changes in directory llvm/tools/llvmc:

CompilerDriver.cpp updated: 1.48 -> 1.49
Makefile updated: 1.24 -> 1.25
---
Log message:

add bitcode support, optimize reading to not read all function bodies just
to get deplibs


---
Diffs of the changes:  (+17 -5)

 CompilerDriver.cpp |   20 ++++++++++++++++----
 Makefile           |    2 +-
 2 files changed, 17 insertions(+), 5 deletions(-)


Index: llvm/tools/llvmc/CompilerDriver.cpp
diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.48 llvm/tools/llvmc/CompilerDriver.cpp:1.49
--- llvm/tools/llvmc/CompilerDriver.cpp:1.48	Sun Apr  8 15:08:01 2007
+++ llvm/tools/llvmc/CompilerDriver.cpp	Sun May  6 00:51:37 2007
@@ -15,7 +15,9 @@
 #include "CompilerDriver.h"
 #include "ConfigLexer.h"
 #include "llvm/Module.h"
+#include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Bytecode/Reader.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/System/Signals.h"
 #include "llvm/ADT/SetVector.h"
@@ -24,6 +26,9 @@
 #include <iostream>
 using namespace llvm;
 
+
+static bool Bitcode = false;
+
 namespace {
 
 void WriteAction(CompilerDriver::Action* action ) {
@@ -66,14 +71,21 @@
                                           Module::LibraryListType& deplibs,
                                           BCDecompressor_t *BCDC,
                                           std::string* ErrMsg) {
-  ModuleProvider* MP = getBytecodeModuleProvider(fname, BCDC, ErrMsg);
+  ModuleProvider *MP = 0;
+  if (Bitcode) {
+    if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&fname[0],
+                                                            fname.size())) {
+      MP = getBitcodeModuleProvider(Buffer);
+      if (MP == 0) delete Buffer;
+    }
+  } else {
+    MP = getBytecodeModuleProvider(fname, BCDC, ErrMsg);
+  }
   if (!MP) {
     deplibs.clear();
     return true;
   }
-  Module* M = MP->releaseModule(ErrMsg);
-  deplibs = M->getLibraries();
-  delete M;
+  deplibs = MP->getModule()->getLibraries();
   delete MP;
   return false;
 }


Index: llvm/tools/llvmc/Makefile
diff -u llvm/tools/llvmc/Makefile:1.24 llvm/tools/llvmc/Makefile:1.25
--- llvm/tools/llvmc/Makefile:1.24	Mon Feb 12 12:31:46 2007
+++ llvm/tools/llvmc/Makefile	Sun May  6 00:51:37 2007
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##
 LEVEL = ../..
 TOOLNAME = llvmc
-LINK_COMPONENTS = support system core bcreader
+LINK_COMPONENTS = support system core bcreader bitreader
 CONFIG_FILES = c cpp ll st
 EXTRA_DIST = c cpp ll ConfigLexer.cpp.cvs ConfigLexer.l.cvs
 REQUIRES_EH := 1






More information about the llvm-commits mailing list