[ThinLTO] Represent relative BF using a scaled representation .
Summary:
The current integer representation of relative block frequency prevents
representing relative block frequencies below 1. This change uses a 8 of
the 29 bits to represent the decimal part by using a fixed scale of -8.
Reviewers: tejohnson, davidxl
Subscribers: mehdi_amini, inglorion, llvm-commits
Differential Revision: https://reviews.llvm.org/D43520
llvm-svn: 325823
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 9293f60..4a84816 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -279,17 +279,9 @@
// Add the relative block frequency to CalleeInfo if there is no profile
// information.
if (BFI != nullptr && Hotness == CalleeInfo::HotnessType::Unknown) {
- auto BBFreq = BFI->getBlockFreq(&BB).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);
+ uint64_t BBFreq = BFI->getBlockFreq(&BB).getFrequency();
+ uint64_t EntryFreq = BFI->getEntryFreq();
+ ValueInfo.updateRelBlockFreq(BBFreq, EntryFreq);
}
} else {
// Skip inline assembly calls.