InstrProf.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //=-- InstrProf.h - Instrumented profiling format support ---------*- 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. // Instrumentation-based profiling data is generated by instrumented
  11. // binaries through library functions in compiler-rt, and read by the clang
  12. // frontend to feed PGO.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_PROFILEDATA_INSTRPROF_H_
  16. #define LLVM_PROFILEDATA_INSTRPROF_H_
  17. #include "llvm/ADT/StringRef.h"
  18. #include <cstdint>
  19. #include <system_error>
  20. #include <vector>
  21. namespace llvm {
  22. const std::error_category &instrprof_category();
  23. enum class instrprof_error {
  24. success = 0,
  25. eof,
  26. bad_magic,
  27. bad_header,
  28. unsupported_version,
  29. unsupported_hash_type,
  30. too_large,
  31. truncated,
  32. malformed,
  33. unknown_function,
  34. hash_mismatch,
  35. count_mismatch,
  36. counter_overflow
  37. };
  38. inline std::error_code make_error_code(instrprof_error E) {
  39. return std::error_code(static_cast<int>(E), instrprof_category());
  40. }
  41. /// Profiling information for a single function.
  42. struct InstrProfRecord {
  43. InstrProfRecord() {}
  44. InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)
  45. : Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
  46. StringRef Name;
  47. uint64_t Hash;
  48. std::vector<uint64_t> Counts;
  49. };
  50. } // end namespace llvm
  51. namespace std {
  52. template <>
  53. struct is_error_code_enum<llvm::instrprof_error> : std::true_type {};
  54. }
  55. #endif // LLVM_PROFILEDATA_INSTRPROF_H_