[llvm] r265370 - [ThinLTO] Refactor some common code into getGlobalValueInfo method (NFC)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 4 17:40:16 PDT 2016
Author: tejohnson
Date: Mon Apr 4 19:40:16 2016
New Revision: 265370
URL: http://llvm.org/viewvc/llvm-project?rev=265370&view=rev
Log:
[ThinLTO] Refactor some common code into getGlobalValueInfo method (NFC)
Refactor common code that queries the ModuleSummaryIndex for a value's
GlobalValueInfo struct into getGlobalValueInfo helper methods, which
will also be used by D18763.
Modified:
llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=265370&r1=265369&r2=265370&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Mon Apr 4 19:40:16 2016
@@ -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;
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=265370&r1=265369&r2=265370&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 4 19:40:16 2016
@@ -5824,12 +5824,7 @@ std::error_code ModuleSummaryIndexBitcod
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 ModuleSummaryIndexBitcod
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;
Modified: llvm/trunk/lib/IR/ModuleSummaryIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ModuleSummaryIndex.cpp?rev=265370&r1=265369&r2=265370&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ModuleSummaryIndex.cpp (original)
+++ llvm/trunk/lib/IR/ModuleSummaryIndex.cpp Mon Apr 4 19:40:16 2016
@@ -68,3 +68,15 @@ void ModuleSummaryIndex::removeEmptySumm
++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();
+}
More information about the llvm-commits
mailing list