InstrProf.cpp revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
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 15#include "llvm/ProfileData/InstrProf.h" 16#include "llvm/Support/ErrorHandling.h" 17 18using namespace llvm; 19 20namespace { 21class InstrProfErrorCategoryType : public error_category { 22 const char *name() const override { return "llvm.instrprof"; } 23 std::string message(int IE) const override { 24 instrprof_error::ErrorType E = static_cast<instrprof_error::ErrorType>(IE); 25 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)"; 32 case instrprof_error::bad_header: 33 return "Invalid header"; 34 case instrprof_error::unsupported_version: 35 return "Unsupported format version"; 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 error_condition default_error_condition(int EV) const { 54 if (EV == instrprof_error::success) 55 return errc::success; 56 return errc::invalid_argument; 57 } 58}; 59} 60 61const error_category &llvm::instrprof_category() { 62 static InstrProfErrorCategoryType C; 63 return C; 64} 65