diff options
author | Easwaran Raman <eraman@google.com> | 2018-01-24 17:51:23 +0000 |
---|---|---|
committer | Easwaran Raman <eraman@google.com> | 2018-01-24 17:51:23 +0000 |
commit | 5f7aff9a0a8b651348b024bd240fdb705d907f12 (patch) | |
tree | 005191f1c92997b6d3b9696ba348433f18d18ee6 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | 4bd8e5332fa5e697bec7ce2cc6642b9708e36e46 (diff) | |
download | llvm-5f7aff9a0a8b651348b024bd240fdb705d907f12.zip llvm-5f7aff9a0a8b651348b024bd240fdb705d907f12.tar.gz llvm-5f7aff9a0a8b651348b024bd240fdb705d907f12.tar.bz2 |
[ThinLTO] Add call edges' relative block frequency to per-module summary.
Summary:
This allows relative block frequency of call edges to be passed to the
thinlink stage where it will be used to compute synthetic entry counts
of functions.
Reviewers: tejohnson, pcc
Subscribers: mehdi_amini, llvm-commits, inglorion
Differential Revision: https://reviews.llvm.org/D42212
llvm-svn: 323349
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index cf2fe77..e4a18b7 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -273,9 +273,24 @@ computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M, // to record the call edge to the alias in that case. Eventually // an alias summary will be created to associate the alias and // aliasee. - CallGraphEdges[Index.getOrInsertValueInfo( - cast<GlobalValue>(CalledValue))] - .updateHotness(Hotness); + auto &ValueInfo = CallGraphEdges[Index.getOrInsertValueInfo( + cast<GlobalValue>(CalledValue))]; + ValueInfo.updateHotness(Hotness); + // Add the relative block frequency to CalleeInfo if there is no profile + // information. + if (BFI != nullptr && Hotness == CalleeInfo::HotnessType::Unknown) { + auto BBFreq = BFI->getBlockFreq(CI->getParent()).getFrequency(); + // FIXME: This might need some scaling to prevent BBFreq values from + // being rounded down to 0. + auto EntryFreq = BFI->getEntryFreq(); + // Block frequencies can be directly set for a block and so we need to + // handle the case of entry frequency being 0. + if (EntryFreq) + BBFreq /= EntryFreq; + else + BBFreq = 0; + ValueInfo.updateRelBlockFreq(BBFreq); + } } else { // Skip inline assembly calls. if (CI && CI->isInlineAsm()) |