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

Devang Patel dpatel at apple.com
Wed Sep 6 11:50:42 PDT 2006



Changes in directory llvm/tools/lto:

lto.cpp updated: 1.10 -> 1.11
---
Log message:

Keep track of all modules crated using a name to module map.
Add private member function getMoudle().


---
Diffs of the changes:  (+18 -1)

 lto.cpp |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletion(-)


Index: llvm/tools/lto/lto.cpp
diff -u llvm/tools/lto/lto.cpp:1.10 llvm/tools/lto/lto.cpp:1.11
--- llvm/tools/lto/lto.cpp:1.10	Tue Sep  5 19:45:52 2006
+++ llvm/tools/lto/lto.cpp	Wed Sep  6 13:50:26 2006
@@ -99,6 +99,23 @@
       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 @@
                                       NameToSymbolMap &symbols,
                                       std::set<std::string> &references)
 {
-  Module *m = ParseBytecodeFile(InputFilename);
+  Module *m = getModule(InputFilename);
   if (!m)
     return LTO_READ_FAILURE;
 






More information about the llvm-commits mailing list