mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user