blob: 01212227206719b2ad18804960a418fce61dc574 [file] [log] [blame]
Justin Bognerf8d79192014-03-21 17:24:48 +00001//=-- 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
15#include "llvm/ProfileData/InstrProf.h"
16#include "llvm/Support/ErrorHandling.h"
17
18using namespace llvm;
19
20namespace {
Rafael Espindola25188c92014-06-12 01:45:43 +000021class InstrProfErrorCategoryType : public std::error_category {
Rafael Espindolaf5d07fa2014-06-10 21:26:47 +000022 const char *name() const LLVM_NOEXCEPT override { return "llvm.instrprof"; }
Justin Bognerf8d79192014-03-21 17:24:48 +000023 std::string message(int IE) const override {
Rafael Espindola92512e82014-06-03 05:12:33 +000024 instrprof_error E = static_cast<instrprof_error>(IE);
Justin Bognerf8d79192014-03-21 17:24:48 +000025 switch (E) {
26 case instrprof_error::success:
27 return "Success";
28 case instrprof_error::eof:
29 return "End of File";
30 case instrprof_error::bad_magic:
31 return "Invalid file format (bad magic)";
Duncan P. N. Exon Smith531bb482014-03-21 20:42:28 +000032 case instrprof_error::bad_header:
33 return "Invalid header";
Justin Bognerf8d79192014-03-21 17:24:48 +000034 case instrprof_error::unsupported_version:
35 return "Unsupported format version";
Justin Bognerb7aa2632014-04-18 21:48:40 +000036 case instrprof_error::unsupported_hash_type:
37 return "Unsupported hash function";
Justin Bognerf8d79192014-03-21 17:24:48 +000038 case instrprof_error::too_large:
39 return "Too much profile data";
40 case instrprof_error::truncated:
41 return "Truncated profile data";
42 case instrprof_error::malformed:
43 return "Malformed profile data";
44 case instrprof_error::unknown_function:
45 return "No profile data available for function";
Justin Bognerb9bd7f82014-03-21 17:46:22 +000046 case instrprof_error::hash_mismatch:
47 return "Function hash mismatch";
48 case instrprof_error::count_mismatch:
49 return "Function count mismatch";
50 case instrprof_error::counter_overflow:
51 return "Counter overflow";
Justin Bognerf8d79192014-03-21 17:24:48 +000052 }
53 llvm_unreachable("A value of instrprof_error has no message.");
54 }
Justin Bognerf8d79192014-03-21 17:24:48 +000055};
56}
57
Rafael Espindola25188c92014-06-12 01:45:43 +000058const std::error_category &llvm::instrprof_category() {
Justin Bognerf8d79192014-03-21 17:24:48 +000059 static InstrProfErrorCategoryType C;
60 return C;
61}