[llvm] bbc629e - [CallPrinter] Fix maxFreq = 0 case
Kirill Bobyrev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 17 01:44:48 PDT 2020
Author: Kirill Bobyrev
Date: 2020-06-17T10:44:28+02:00
New Revision: bbc629ebd6429d43cfd72d9a0e2b5ca8a4083b54
URL: https://github.com/llvm/llvm-project/commit/bbc629ebd6429d43cfd72d9a0e2b5ca8a4083b54
DIFF: https://github.com/llvm/llvm-project/commit/bbc629ebd6429d43cfd72d9a0e2b5ca8a4083b54.diff
LOG: [CallPrinter] Fix maxFreq = 0 case
llvm::getHeatColor becomes a problem when maxFreq = 0 -> freq = 0 =>
log2(double(freq)) / log2(maxFreq) -> log2(0.) / log2(0.) which
results in illegal instruction on some architectures.
Problematic revision: https://reviews.llvm.org/D77172
Added:
Modified:
llvm/lib/Analysis/HeatUtils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/HeatUtils.cpp b/llvm/lib/Analysis/HeatUtils.cpp
index 99d39d8bbe9e..15d672ffbf9a 100644
--- a/llvm/lib/Analysis/HeatUtils.cpp
+++ b/llvm/lib/Analysis/HeatUtils.cpp
@@ -62,7 +62,7 @@ uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI) {
std::string getHeatColor(uint64_t freq, uint64_t maxFreq) {
if (freq > maxFreq)
freq = maxFreq;
- double percent = log2(double(freq)) / log2(maxFreq);
+ double percent = (maxFreq > 0) ? log2(double(freq)) / log2(maxFreq) : 0;
return getHeatColor(percent);
}
More information about the llvm-commits
mailing list