diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-04-24 14:57:11 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-04-24 14:57:11 +0000 |
commit | 28e457bccd6d1dd6ba91d36253073372a1bb5d75 (patch) | |
tree | 5368e89d5262e31ef567218d31c72a894cde3f5c /llvm/lib/IR/ModuleSummaryIndex.cpp | |
parent | 9f5697ef6803acededad77a51b40a3fbec905c81 (diff) | |
download | llvm-28e457bccd6d1dd6ba91d36253073372a1bb5d75.zip llvm-28e457bccd6d1dd6ba91d36253073372a1bb5d75.tar.gz llvm-28e457bccd6d1dd6ba91d36253073372a1bb5d75.tar.bz2 |
[ThinLTO] Remove GlobalValueInfo class from index
Summary:
Remove the GlobalValueInfo and change the ModuleSummaryIndex to directly
reference summary objects. The info structure was there to support lazy
parsing of the combined index summary objects, which is no longer
needed and not supported.
Reviewers: joker.eph
Subscribers: joker.eph, llvm-commits
Differential Revision: http://reviews.llvm.org/D19462
llvm-svn: 267344
Diffstat (limited to 'llvm/lib/IR/ModuleSummaryIndex.cpp')
-rw-r--r-- | llvm/lib/IR/ModuleSummaryIndex.cpp | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp index 8ca5e27..4c122c7 100644 --- a/llvm/lib/IR/ModuleSummaryIndex.cpp +++ b/llvm/lib/IR/ModuleSummaryIndex.cpp @@ -22,38 +22,34 @@ void ModuleSummaryIndex::mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other, uint64_t NextModuleId) { StringRef ModPath; - for (auto &OtherGlobalValInfoLists : *Other) { - GlobalValue::GUID ValueGUID = OtherGlobalValInfoLists.first; - GlobalValueInfoList &List = OtherGlobalValInfoLists.second; + for (auto &OtherGlobalValSummaryLists : *Other) { + GlobalValue::GUID ValueGUID = OtherGlobalValSummaryLists.first; + GlobalValueSummaryList &List = OtherGlobalValSummaryLists.second; - // Assert that the value info list only has one entry, since we shouldn't + // Assert that the value summary list only has one entry, since we shouldn't // have duplicate names within a single per-module index. assert(List.size() == 1); - std::unique_ptr<GlobalValueInfo> Info = std::move(List.front()); - - // Skip if there was no summary section. - if (!Info->summary()) - continue; + std::unique_ptr<GlobalValueSummary> Summary = std::move(List.front()); // Add the module path string ref for this module if we haven't already // saved a reference to it. if (ModPath.empty()) { - auto Path = Info->summary()->modulePath(); + auto Path = Summary->modulePath(); ModPath = addModulePath(Path, NextModuleId, Other->getModuleHash(Path)) ->first(); } else - assert(ModPath == Info->summary()->modulePath() && + assert(ModPath == Summary->modulePath() && "Each module in the combined map should have a unique ID"); // Note the module path string ref was copied above and is still owned by // the original per-module index. Reset it to the new module path // string reference owned by the combined index. - Info->summary()->setModulePath(ModPath); + Summary->setModulePath(ModPath); - // Add new value info to existing list. There may be duplicates when + // Add new value summary to existing list. There may be duplicates when // combining GlobalValueMap entries, due to COMDAT values. Any local // values were given unique global IDs. - addGlobalValueInfo(ValueGUID, std::move(Info)); + addGlobalValueSummary(ValueGUID, std::move(Summary)); } } @@ -62,7 +58,7 @@ void ModuleSummaryIndex::removeEmptySummaryEntries() { // Only expect this to be called on a per-module index, which has a single // entry per value entry list. assert(MI->second.size() == 1); - if (!MI->second[0]->summary()) + if (!MI->second[0]) MI = GlobalValueMap.erase(MI); else ++MI; @@ -73,42 +69,41 @@ void ModuleSummaryIndex::removeEmptySummaryEntries() { // (GUID -> Summary). void ModuleSummaryIndex::collectDefinedFunctionsForModule( StringRef ModulePath, - std::map<GlobalValue::GUID, GlobalValueSummary *> &FunctionInfoMap) const { + std::map<GlobalValue::GUID, GlobalValueSummary *> &GVSummaryMap) const { for (auto &GlobalList : *this) { auto GUID = GlobalList.first; - for (auto &GlobInfo : GlobalList.second) { - auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobInfo->summary()); + for (auto &GlobSummary : GlobalList.second) { + auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobSummary.get()); if (!Summary) // Ignore global variable, focus on functions continue; // Ignore summaries from other modules. if (Summary->modulePath() != ModulePath) continue; - FunctionInfoMap[GUID] = Summary; + GVSummaryMap[GUID] = Summary; } } } // Collect for each module the list of function it defines (GUID -> Summary). void ModuleSummaryIndex::collectDefinedGVSummariesPerModule( - StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> & - Module2FunctionInfoMap) const { + StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> + &ModuleToDefinedGVSummaries) const { for (auto &GlobalList : *this) { auto GUID = GlobalList.first; - for (auto &GlobInfo : GlobalList.second) { - auto *Summary = GlobInfo->summary(); - Module2FunctionInfoMap[Summary->modulePath()][GUID] = Summary; + for (auto &Summary : GlobalList.second) { + ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get(); } } } -GlobalValueInfo * -ModuleSummaryIndex::getGlobalValueInfo(uint64_t ValueGUID, - bool PerModuleIndex) const { - auto InfoList = findGlobalValueInfoList(ValueGUID); - assert(InfoList != end() && "GlobalValue not found in index"); - assert((!PerModuleIndex || InfoList->second.size() == 1) && +GlobalValueSummary * +ModuleSummaryIndex::getGlobalValueSummary(uint64_t ValueGUID, + bool PerModuleIndex) const { + auto SummaryList = findGlobalValueSummaryList(ValueGUID); + assert(SummaryList != end() && "GlobalValue not found in index"); + assert((!PerModuleIndex || SummaryList->second.size() == 1) && "Expected a single entry per global value in per-module index"); - auto &Info = InfoList->second[0]; - return Info.get(); + auto &Summary = SummaryList->second[0]; + return Summary.get(); } |