forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e51c1d06a9
commit
bbc629ebd6
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue