blob: b665e211c6ac21c3712b4960fc88383762a4013f [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===-- 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
20namespace llvm {
21
22class BlockFrequencyInfo;
23class Function;
24
25// Returns number of calls of calledFunction by callerFunction.
26uint64_t
27getNumOfCalls(Function &callerFunction, Function &calledFunction);
28
29// Returns the maximum frequency of a BB in a function.
30uint64_t getMaxFreq(const Function &F, const BlockFrequencyInfo *BFI);
31
32// Calculates heat color based on current and maximum frequencies.
33std::string getHeatColor(uint64_t freq, uint64_t maxFreq);
34
35// Calculates heat color based on percent of "hotness".
36std::string getHeatColor(double percent);
37
38} // namespace llvm
39
40#endif