diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-16 07:02:16 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-16 07:02:16 +0000 |
commit | 1aafabf752a41bd0e0e565d6d02d7b43f4c5907e (patch) | |
tree | cc14de872cc7f10ecc39feef4681d46d171ee462 /llvm/lib/Transforms/IPO/FunctionImport.cpp | |
parent | 71c8440e553b6208b199a4c9c98229ce88ba0c60 (diff) | |
download | bcm5719-llvm-1aafabf752a41bd0e0e565d6d02d7b43f4c5907e.tar.gz bcm5719-llvm-1aafabf752a41bd0e0e565d6d02d7b43f4c5907e.zip |
ThinLTO: Move the ODR resolution to be based purely on the summary.
This is a requirement for the cache handling in D18494
Differential Revision: http://reviews.llvm.org/D18908
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266519
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index d6dfe17518b..91e3695c351 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -143,7 +143,7 @@ using EdgeInfo = std::pair<const FunctionSummary *, unsigned /* Threshold */>; static void computeImportForFunction( const FunctionSummary &Summary, const ModuleSummaryIndex &Index, unsigned Threshold, - const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedFunctions, + const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedGVSummaries, SmallVectorImpl<EdgeInfo> &Worklist, FunctionImporter::ImportMapTy &ImportsForModule, StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) { @@ -151,7 +151,7 @@ static void computeImportForFunction( auto GUID = Edge.first.getGUID(); DEBUG(dbgs() << " edge -> " << GUID << " Threshold:" << Threshold << "\n"); - if (DefinedFunctions.count(GUID)) { + if (DefinedGVSummaries.count(GUID)) { DEBUG(dbgs() << "ignored! Target already in destination module.\n"); continue; } @@ -212,7 +212,7 @@ static void computeImportForFunction( /// as well as the list of "exports", i.e. the list of symbols referenced from /// another module (that may require promotion). static void ComputeImportForModule( - const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedFunctions, + const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedGVSummaries, const ModuleSummaryIndex &Index, FunctionImporter::ImportMapTy &ImportsForModule, StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) { @@ -222,14 +222,17 @@ static void ComputeImportForModule( // Populate the worklist with the import for the functions in the current // module - for (auto &FuncInfo : DefinedFunctions) { - auto *Summary = FuncInfo.second; + for (auto &GVInfo : DefinedGVSummaries) { + auto *Summary = GVInfo.second; if (auto *AS = dyn_cast<AliasSummary>(Summary)) Summary = &AS->getAliasee(); - auto *FuncSummary = cast<FunctionSummary>(Summary); - DEBUG(dbgs() << "Initalize import for " << FuncInfo.first << "\n"); + auto *FuncSummary = dyn_cast<FunctionSummary>(Summary); + if (!FuncSummary) + // Skip import for global variables + continue; + DEBUG(dbgs() << "Initalize import for " << GVInfo.first << "\n"); computeImportForFunction(*FuncSummary, Index, ImportInstrLimit, - DefinedFunctions, Worklist, ImportsForModule, + DefinedGVSummaries, Worklist, ImportsForModule, ExportLists); } @@ -242,7 +245,7 @@ static void ComputeImportForModule( // Adjust the threshold Threshold = Threshold * ImportInstrFactor; - computeImportForFunction(*Summary, Index, Threshold, DefinedFunctions, + computeImportForFunction(*Summary, Index, Threshold, DefinedGVSummaries, Worklist, ImportsForModule, ExportLists); } } @@ -252,38 +255,16 @@ static void ComputeImportForModule( /// Compute all the import and export for every module using the Index. void llvm::ComputeCrossModuleImport( const ModuleSummaryIndex &Index, + const StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> & + ModuleToDefinedGVSummaries, StringMap<FunctionImporter::ImportMapTy> &ImportLists, StringMap<FunctionImporter::ExportSetTy> &ExportLists) { - auto ModuleCount = Index.modulePaths().size(); - - // Collect for each module the list of function it defines. - // GUID -> Summary - StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> - Module2FunctionInfoMap(ModuleCount); - - for (auto &GlobalList : Index) { - auto GUID = GlobalList.first; - for (auto &GlobInfo : GlobalList.second) { - auto *Summary = GlobInfo->summary(); - if (isa<GlobalVarSummary>(Summary)) - /// Ignore global variable, focus on functions - continue; - if (auto *AS = dyn_cast<AliasSummary>(Summary)) - if (isa<GlobalVarSummary>(&AS->getAliasee())) - /// Ignore alias to global variable, focus on functions - continue; - DEBUG(dbgs() << "Adding definition: Module '" << Summary->modulePath() - << "' defines '" << GUID << "'\n"); - Module2FunctionInfoMap[Summary->modulePath()][GUID] = Summary; - } - } - // For each module that has function defined, compute the import/export lists. - for (auto &DefinedFunctions : Module2FunctionInfoMap) { - auto &ImportsForModule = ImportLists[DefinedFunctions.first()]; - DEBUG(dbgs() << "Computing import for Module '" << DefinedFunctions.first() - << "'\n"); - ComputeImportForModule(DefinedFunctions.second, Index, ImportsForModule, + for (auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) { + auto &ImportsForModule = ImportLists[DefinedGVSummaries.first()]; + DEBUG(dbgs() << "Computing import for Module '" + << DefinedGVSummaries.first() << "'\n"); + ComputeImportForModule(DefinedGVSummaries.second, Index, ImportsForModule, &ExportLists); } |