[CallPrinter] Handle freq = 0 case

Improvement of the following revision:
bbc629ebd6

This might still be problematic if freq = 0, so it's better to check for
that.
This commit is contained in:
Kirill Bobyrev
2020-06-17 10:52:18 +02:00
parent bbc629ebd6
commit 3847737fa4
+1 -1
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 = (maxFreq > 0) ? log2(double(freq)) / log2(maxFreq) : 0;
double percent = (freq > 0) ? log2(double(freq)) / log2(maxFreq) : 0;
return getHeatColor(percent);
}