[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:
Kirill Bobyrev 2020-06-17 10:44:28 +02:00
parent e51c1d06a9
commit bbc629ebd6
No known key found for this signature in database
GPG Key ID: 2307C055C8384FA0
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}