summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/InstrProf.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-03-21 17:24:48 +0000
committerJustin Bogner <mail@justinbogner.com>2014-03-21 17:24:48 +0000
commitf8d791983cfc4a86a6d1a7186aa65bfbecf4c5c5 (patch)
tree6c24d9230524c8d8f984e849127965661a814767 /llvm/lib/ProfileData/InstrProf.cpp
parentd8eb29ecfd7ec7f4744bc7ea52e13bbebecea430 (diff)
downloadbcm5719-llvm-f8d791983cfc4a86a6d1a7186aa65bfbecf4c5c5.tar.gz
bcm5719-llvm-f8d791983cfc4a86a6d1a7186aa65bfbecf4c5c5.zip
ProfileData: Introduce the InstrProfReader interface and a text reader
This introduces the ProfileData library and updates llvm-profdata to use this library for reading profiles. InstrProfReader is an abstract base class that will be subclassed for both the raw instrprof data from compiler-rt and the efficient instrprof format that will be used for PGO. llvm-svn: 204482
Diffstat (limited to 'llvm/lib/ProfileData/InstrProf.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
new file mode 100644
index 00000000000..329abf84e6e
--- /dev/null
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -0,0 +1,56 @@
+//=-- 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::unsupported_version:
+ return "Unsupported format version";
+ 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";
+ }
+ llvm_unreachable("A value of instrprof_error has no message.");
+ }
+ error_condition default_error_condition(int EV) const {
+ if (EV == instrprof_error::success)
+ return errc::success;
+ return errc::invalid_argument;
+ }
+};
+}
+
+const error_category &llvm::instrprof_category() {
+ static InstrProfErrorCategoryType C;
+ return C;
+}
OpenPOWER on IntegriCloud