LLVM API Documentation

InstrProf.cpp
Go to the documentation of this file.
00001 //=-- InstrProf.cpp - Instrumented profiling format support -----------------=//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains support for clang's instrumentation based PGO and
00011 // coverage.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "llvm/ProfileData/InstrProf.h"
00016 #include "llvm/Support/ErrorHandling.h"
00017 
00018 using namespace llvm;
00019 
00020 namespace {
00021 class InstrProfErrorCategoryType : public std::error_category {
00022   const char *name() const LLVM_NOEXCEPT override { return "llvm.instrprof"; }
00023   std::string message(int IE) const override {
00024     instrprof_error E = static_cast<instrprof_error>(IE);
00025     switch (E) {
00026     case instrprof_error::success:
00027       return "Success";
00028     case instrprof_error::eof:
00029       return "End of File";
00030     case instrprof_error::bad_magic:
00031       return "Invalid file format (bad magic)";
00032     case instrprof_error::bad_header:
00033       return "Invalid header";
00034     case instrprof_error::unsupported_version:
00035       return "Unsupported format version";
00036     case instrprof_error::unsupported_hash_type:
00037       return "Unsupported hash function";
00038     case instrprof_error::too_large:
00039       return "Too much profile data";
00040     case instrprof_error::truncated:
00041       return "Truncated profile data";
00042     case instrprof_error::malformed:
00043       return "Malformed profile data";
00044     case instrprof_error::unknown_function:
00045       return "No profile data available for function";
00046     case instrprof_error::hash_mismatch:
00047       return "Function hash mismatch";
00048     case instrprof_error::count_mismatch:
00049       return "Function count mismatch";
00050     case instrprof_error::counter_overflow:
00051       return "Counter overflow";
00052     }
00053     llvm_unreachable("A value of instrprof_error has no message.");
00054   }
00055 };
00056 }
00057 
00058 const std::error_category &llvm::instrprof_category() {
00059   static InstrProfErrorCategoryType C;
00060   return C;
00061 }