InstrProf.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //=-- InstrProf.cpp - Instrumented profiling format support -----------------=//
  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. // This file contains support for clang's instrumentation based PGO and
  11. // coverage.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include "llvm/ProfileData/InstrProf.h"
  15. #include "llvm/Support/ErrorHandling.h"
  16. #include "llvm/Support/ManagedStatic.h"
  17. using namespace llvm;
  18. namespace {
  19. class InstrProfErrorCategoryType : public std::error_category {
  20. const char *name() const LLVM_NOEXCEPT override { return "llvm.instrprof"; }
  21. std::string message(int IE) const override {
  22. instrprof_error E = static_cast<instrprof_error>(IE);
  23. switch (E) {
  24. case instrprof_error::success:
  25. return "Success";
  26. case instrprof_error::eof:
  27. return "End of File";
  28. case instrprof_error::bad_magic:
  29. return "Invalid profile data (bad magic)";
  30. case instrprof_error::bad_header:
  31. return "Invalid profile data (file header is corrupt)";
  32. case instrprof_error::unsupported_version:
  33. return "Unsupported profiling format version";
  34. case instrprof_error::unsupported_hash_type:
  35. return "Unsupported profiling hash";
  36. case instrprof_error::too_large:
  37. return "Too much profile data";
  38. case instrprof_error::truncated:
  39. return "Truncated profile data";
  40. case instrprof_error::malformed:
  41. return "Malformed profile data";
  42. case instrprof_error::unknown_function:
  43. return "No profile data available for function";
  44. case instrprof_error::hash_mismatch:
  45. return "Function hash mismatch";
  46. case instrprof_error::count_mismatch:
  47. return "Function count mismatch";
  48. case instrprof_error::counter_overflow:
  49. return "Counter overflow";
  50. }
  51. llvm_unreachable("A value of instrprof_error has no message.");
  52. }
  53. };
  54. }
  55. static ManagedStatic<InstrProfErrorCategoryType> ErrorCategory;
  56. const std::error_category &llvm::instrprof_category() {
  57. return *ErrorCategory;
  58. }