summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h14
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp14
-rw-r--r--llvm/lib/IR/ModuleSummaryIndex.cpp12
3 files changed, 28 insertions, 12 deletions
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index b4240e7aee9..681ebd4dc60 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -309,6 +309,20 @@ public:
GlobalValueMap[ValueGUID].push_back(std::move(Info));
}
+ /// Returns the first GlobalValueInfo for \p GV, asserting that there
+ /// is only one if \p PerModuleIndex.
+ GlobalValueInfo *getGlobalValueInfo(const GlobalValue &GV,
+ bool PerModuleIndex = true) const {
+ assert(GV.hasName() && "Can't get GlobalValueInfo for GV with no name");
+ return getGlobalValueInfo(GlobalValue::getGUID(GV.getName()),
+ PerModuleIndex);
+ }
+
+ /// Returns the first GlobalValueInfo for \p ValueGUID, asserting that there
+ /// is only one if \p PerModuleIndex.
+ GlobalValueInfo *getGlobalValueInfo(GlobalValue::GUID ValueGUID,
+ bool PerModuleIndex = true) const;
+
/// Table of modules, containing module hash and id.
const StringMap<std::pair<uint64_t, ModuleHash>> &modulePaths() const {
return ModulePathStringTable;
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 09e5220b919..39f2d6ae333 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5824,12 +5824,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
CalleeInfo(CallsiteCount, ProfileCount));
}
GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
- auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
- assert(InfoList != TheIndex->end() &&
- "Expected VST parse to create GlobalValueInfo entry");
- assert(InfoList->second.size() == 1 &&
- "Expected a single GlobalValueInfo per GUID in module");
- auto &Info = InfoList->second[0];
+ auto *Info = TheIndex->getGlobalValueInfo(GUID);
assert(!Info->summary() && "Expected a single summary per VST entry");
Info->setSummary(std::move(FS));
break;
@@ -5848,12 +5843,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
FS->addRefEdge(RefGUID);
}
GlobalValue::GUID GUID = getGUIDFromValueId(ValueID);
- auto InfoList = TheIndex->findGlobalValueInfoList(GUID);
- assert(InfoList != TheIndex->end() &&
- "Expected VST parse to create GlobalValueInfo entry");
- assert(InfoList->second.size() == 1 &&
- "Expected a single GlobalValueInfo per GUID in module");
- auto &Info = InfoList->second[0];
+ auto *Info = TheIndex->getGlobalValueInfo(GUID);
assert(!Info->summary() && "Expected a single summary per VST entry");
Info->setSummary(std::move(FS));
break;
diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index 5effc65158d..340eccac6bd 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -68,3 +68,15 @@ void ModuleSummaryIndex::removeEmptySummaryEntries() {
++MI;
}
}
+
+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 &&
+ "Expected a single entry per global value in per-module index");
+ auto &Info = InfoList->second[0];
+ return Info.get();
+}
OpenPOWER on IntegriCloud