aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ProfileData/InstrProf.cpp
blob: de2b13dafd028e44d24899ce145820294d3c2d70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//=-- InstrProf.cpp - Instrumented profiling format support -----------------=//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains support for clang's instrumentation based PGO and
// coverage.
//
//===----------------------------------------------------------------------===//

#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/ErrorHandling.h"

using namespace llvm;

namespace {
class InstrProfErrorCategoryType : public error_category {
  const char *name() const override { return "llvm.instrprof"; }
  std::string message(int IE) const override {
    instrprof_error::ErrorType E = static_cast<instrprof_error::ErrorType>(IE);
    switch (E) {
    case instrprof_error::success:
      return "Success";
    case instrprof_error::eof:
      return "End of File";
    case instrprof_error::bad_magic:
      return "Invalid file format (bad magic)";
    case instrprof_error::bad_header:
      return "Invalid header";
    case instrprof_error::unsupported_version:
      return "Unsupported format version";
    case instrprof_error::unsupported_hash_type:
      return "Unsupported hash function";
    case instrprof_error::too_large:
      return "Too much profile data";
    case instrprof_error::truncated:
      return "Truncated profile data";
    case instrprof_error::malformed:
      return "Malformed profile data";
    case instrprof_error::unknown_function:
      return "No profile data available for function";
    case instrprof_error::hash_mismatch:
      return "Function hash mismatch";
    case instrprof_error::count_mismatch:
      return "Function count mismatch";
    case instrprof_error::counter_overflow:
      return "Counter overflow";
    }
    llvm_unreachable("A value of instrprof_error has no message.");
  }
  error_condition default_error_condition(int EV) const override {
    if (EV == instrprof_error::success)
      return errc::success;
    return errc::invalid_argument;
  }
};
}

const error_category &llvm::instrprof_category() {
  static InstrProfErrorCategoryType C;
  return C;
}