1 //=-- InstrProf.cpp - Instrumented profiling format support -----------------=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for clang's instrumentation based PGO and
13 //===----------------------------------------------------------------------===//
15 #include "llvm/ProfileData/InstrProf.h"
16 #include "llvm/Support/ErrorHandling.h"
17 #include "llvm/Support/ManagedStatic.h"
22 class InstrProfErrorCategoryType : public std::error_category {
23 const char *name() const LLVM_NOEXCEPT override { return "llvm.instrprof"; }
24 std::string message(int IE) const override {
25 instrprof_error E = static_cast<instrprof_error>(IE);
27 case instrprof_error::success:
29 case instrprof_error::eof:
31 case instrprof_error::bad_magic:
32 return "Invalid profile data (bad magic)";
33 case instrprof_error::bad_header:
34 return "Invalid profile data (file header is corrupt)";
35 case instrprof_error::unsupported_version:
36 return "Unsupported profiling format version";
37 case instrprof_error::unsupported_hash_type:
38 return "Unsupported profiling hash";
39 case instrprof_error::too_large:
40 return "Too much profile data";
41 case instrprof_error::truncated:
42 return "Truncated profile data";
43 case instrprof_error::malformed:
44 return "Malformed profile data";
45 case instrprof_error::unknown_function:
46 return "No profile data available for function";
47 case instrprof_error::hash_mismatch:
48 return "Function hash mismatch";
49 case instrprof_error::count_mismatch:
50 return "Function count mismatch";
51 case instrprof_error::counter_overflow:
52 return "Counter overflow";
54 llvm_unreachable("A value of instrprof_error has no message.");
59 static ManagedStatic<InstrProfErrorCategoryType> ErrorCategory;
61 const std::error_category &llvm::instrprof_category() {
62 return *ErrorCategory;