1 //===-- HeatUtils.h - Utility for printing heat colors ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Utility for printing heat colors based on profiling information.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_HEATUTILS_H
15 #define LLVM_ANALYSIS_HEATUTILS_H
16 
17 #include <cstdint>
18 #include <string>
19 
20 namespace llvm {
21 
22 class BlockFrequencyInfo;
23 class Function;
24 
25 // Returns number of calls of calledFunction by callerFunction.
26 uint64_t
27 getNumOfCalls(Function &callerFunction, Function &calledFunction);
28 
29 // Returns the maximum frequency of a BB in a function.
30 uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI);
31 
32 // Calculates heat color based on current and maximum frequencies.
33 std::string getHeatColor(uint64_t freq, uint64_t maxFreq);
34 
35 // Calculates heat color based on percent of "hotness".
36 std::string getHeatColor(double percent);
37 
38 } // namespace llvm
39 
40 #endif
41