aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ProfileData/InstrProf.h
blob: d8f3ca6b9d85cd3f89f09e31fe76fa86d34f2f3e (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
//=-- InstrProf.h - Instrumented profiling format support ---------*- C++ -*-=//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Instrumentation-based profiling data is generated by instrumented
// binaries through library functions in compiler-rt, and read by the clang
// frontend to feed PGO.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_PROFILEDATA_INSTRPROF_H_
#define LLVM_PROFILEDATA_INSTRPROF_H_

#include "llvm/Support/system_error.h"

namespace llvm {

const error_category &instrprof_category();

struct instrprof_error {
  enum ErrorType {
    success = 0,
    eof,
    bad_magic,
    bad_header,
    unsupported_version,
    too_large,
    truncated,
    malformed,
    unknown_function,
    hash_mismatch,
    count_mismatch,
    counter_overflow
  };
  ErrorType V;

  instrprof_error(ErrorType V) : V(V) {}
  operator ErrorType() const { return V; }
};

inline error_code make_error_code(instrprof_error E) {
  return error_code(static_cast<int>(E), instrprof_category());
}

template <> struct is_error_code_enum<instrprof_error> : std::true_type {};
template <> struct is_error_code_enum<instrprof_error::ErrorType>
  : std::true_type {};

} // end namespace llvm

#endif // LLVM_PROFILEDATA_INSTRPROF_H_