diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-06 05:51:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-06 05:51:37 +0000 |
commit | 5e8edbbf1183e49cf0223840805b01f107803c3a (patch) | |
tree | baecd9f83c09ca43edf17ff641c8615d62d3de74 /tools/llvmc | |
parent | db9cbeb2408ecfe97a2e0065492b1f37caf377ad (diff) | |
download | external_llvm-5e8edbbf1183e49cf0223840805b01f107803c3a.zip external_llvm-5e8edbbf1183e49cf0223840805b01f107803c3a.tar.gz external_llvm-5e8edbbf1183e49cf0223840805b01f107803c3a.tar.bz2 |
add bitcode support, optimize reading to not read all function bodies just
to get deplibs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc')
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 20 | ||||
-rw-r--r-- | tools/llvmc/Makefile | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index 46015df..251da34 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -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 @@ static bool GetBytecodeDependentLibraries(const std::string &fname, 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; } diff --git a/tools/llvmc/Makefile b/tools/llvmc/Makefile index d762f984..4c66afc 100644 --- a/tools/llvmc/Makefile +++ b/tools/llvmc/Makefile @@ -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 |