HeatUtils.h 1.3 KB

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