summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 80db5b2e061..c62cd1f2042 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3331,11 +3331,16 @@ void ModuleBitcodeWriter::writePerModuleFunctionSummaryRecord(
void ModuleBitcodeWriter::writeModuleLevelReferences(
const GlobalVariable &V, SmallVector<uint64_t, 64> &NameVals,
unsigned FSModRefsAbbrev) {
- // Only interested in recording variable defs in the summary.
- if (V.isDeclaration())
+ auto Summaries =
+ Index->findGlobalValueSummaryList(GlobalValue::getGUID(V.getName()));
+ if (Summaries == Index->end()) {
+ // Only declarations should not have a summary (a declaration might however
+ // have a summary if the def was in module level asm).
+ assert(V.isDeclaration());
return;
+ }
+ auto *Summary = Summaries->second.front().get();
NameVals.push_back(VE.getValueID(&V));
- auto *Summary = Index->getGlobalValueSummary(V);
GlobalVarSummary *VS = cast<GlobalVarSummary>(Summary);
NameVals.push_back(getEncodedGVSummaryFlags(VS->flags()));
@@ -3413,14 +3418,20 @@ void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
// Iterate over the list of functions instead of the Index to
// ensure the ordering is stable.
for (const Function &F : M) {
- if (F.isDeclaration())
- continue;
// Summary emission does not support anonymous functions, they have to
// renamed using the anonymous function renaming pass.
if (!F.hasName())
report_fatal_error("Unexpected anonymous function when writing summary");
- auto *Summary = Index->getGlobalValueSummary(F);
+ auto Summaries =
+ Index->findGlobalValueSummaryList(GlobalValue::getGUID(F.getName()));
+ if (Summaries == Index->end()) {
+ // Only declarations should not have a summary (a declaration might
+ // however have a summary if the def was in module level asm).
+ assert(F.isDeclaration());
+ continue;
+ }
+ auto *Summary = Summaries->second.front().get();
writePerModuleFunctionSummaryRecord(NameVals, Summary, VE.getValueID(&F),
FSCallsAbbrev, FSCallsProfileAbbrev, F);
}
OpenPOWER on IntegriCloud