HeatUtils.h 1.4 KB

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