mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Keep track of all modules crated using a name to module map.
Add private member function getMoudle(). llvm-svn: 30130
This commit is contained in:
parent
1a6e014f29
commit
bb3ca8e494
@ -83,6 +83,8 @@ namespace llvm {
|
||||
public:
|
||||
typedef hash_map<const char*, LLVMSymbol*, hash<const char*>,
|
||||
string_compare> NameToSymbolMap;
|
||||
typedef hash_map<const char*, Module*, hash<const char*>,
|
||||
string_compare> NameToModuleMap;
|
||||
|
||||
enum LTOStatus readLLVMObjectFile(const std::string &InputFilename,
|
||||
NameToSymbolMap &symbols,
|
||||
@ -91,9 +93,13 @@ namespace llvm {
|
||||
std::vector<const char*> &exportList,
|
||||
std::string &targetTriple);
|
||||
|
||||
private:
|
||||
Module *getModule (const std::string &InputFilename);
|
||||
|
||||
private:
|
||||
std::vector<Module *> modules;
|
||||
NameToSymbolMap allSymbols;
|
||||
NameToModuleMap allModules;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user