diff options
author | Devang Patel <dpatel@apple.com> | 2006-09-06 18:50:26 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-09-06 18:50:26 +0000 |
commit | 0701a2f70df66134ead84d4fe86b20b8f28c4fc3 (patch) | |
tree | 2b6a5a67e1c569a95a73910325c0dd21c629c42d /tools/lto | |
parent | 3fc488d0ce9477834229064571c1709d7435f924 (diff) | |
download | external_llvm-0701a2f70df66134ead84d4fe86b20b8f28c4fc3.zip external_llvm-0701a2f70df66134ead84d4fe86b20b8f28c4fc3.tar.gz external_llvm-0701a2f70df66134ead84d4fe86b20b8f28c4fc3.tar.bz2 |
Keep track of all modules crated using a name to module map.
Add private member function getMoudle().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index e49364e..96b449e 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -99,6 +99,23 @@ findExternalRefs(Value *value, std::set<std::string> &references, findExternalRefs(c->getOperand(i), references, mangler); } +/// InputFilename is a LLVM bytecode file. If Module with InputFilename is +/// available then return it. Otherwise parseInputFilename. +Module * +LinkTimeOptimizer::getModule(const std::string &InputFilename) +{ + Module *m = NULL; + + NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str()); + if (pos != allModules.end()) + m = allModules[InputFilename.c_str()]; + else { + m = ParseBytecodeFile(InputFilename); + allModules[InputFilename.c_str()] = m; + } + return m; +} + /// InputFilename is a LLVM bytecode file. Read it using bytecode reader. /// Collect global functions and symbol names in symbols vector. /// Collect external references in references vector. @@ -108,7 +125,7 @@ LinkTimeOptimizer::readLLVMObjectFile(const std::string &InputFilename, NameToSymbolMap &symbols, std::set<std::string> &references) { - Module *m = ParseBytecodeFile(InputFilename); + Module *m = getModule(InputFilename); if (!m) return LTO_READ_FAILURE; |