1 //===-- HeatUtils.h - Utility for printing heat colors ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Utility for printing heat colors based on profiling information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_HEATUTILS_H
14 #define LLVM_ANALYSIS_HEATUTILS_H
15 
16 #include <cstdint>
17 #include <string>
18 
19 namespace llvm {
20 
21 class BlockFrequencyInfo;
22 class Function;
23 
24 // Returns number of calls of calledFunction by callerFunction.
25 uint64_t
26 getNumOfCalls(Function &callerFunction, Function &calledFunction);
27 
28 // Returns the maximum frequency of a BB in a function.
29 uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI);
30 
31 // Calculates heat color based on current and maximum frequencies.
32 std::string getHeatColor(uint64_t freq, uint64_t maxFreq);
33 
34 // Calculates heat color based on percent of "hotness".
35 std::string getHeatColor(double percent);
36 
37 } // namespace llvm
38 
39 #endif
40