diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-04-18 21:52:00 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-04-18 21:52:00 +0000 |
commit | 837a6f6f79fc44bf6467ac874f4e3c411a62bedf (patch) | |
tree | f6cd2dd6cdd0f5c5b34748f418ccafd2ff911133 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | fc83c1105c698c343a11e238ba6b93464fe8c5df (diff) | |
download | llvm-837a6f6f79fc44bf6467ac874f4e3c411a62bedf.zip llvm-837a6f6f79fc44bf6467ac874f4e3c411a62bedf.tar.gz llvm-837a6f6f79fc44bf6467ac874f4e3c411a62bedf.tar.bz2 |
CodeGen: Use LLVM's InstrProfReader in -fprofile-instr-use=
Update clang to use the InstrProfReader from LLVM to read
instrumentation based profile data. This also switches us from the
naive text format to the binary format, since that's what's
implemented in the reader.
llvm-svn: 206658
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d4daaa5..69a9092 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -47,6 +47,7 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" +#include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" @@ -78,7 +79,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(0), TheTargetCodeGenInfo(0), Types(*this), VTables(*this), ObjCRuntime(0), OpenCLRuntime(0), CUDARuntime(0), DebugInfo(0), ARCData(0), - NoObjCARCExceptionsMetadata(0), RRData(0), PGOData(0), + NoObjCARCExceptionsMetadata(0), RRData(0), PGOReader(nullptr), CFConstantStringClassRef(0), ConstantStringClassRef(0), NSConstantStringType(0), NSConcreteGlobalBlock(0), NSConcreteStackBlock(0), BlockObjectAssign(0), @@ -134,8 +135,14 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, ARCData = new ARCEntrypoints(); RRData = new RREntrypoints(); - if (!CodeGenOpts.InstrProfileInput.empty()) - PGOData = new PGOProfileData(*this, CodeGenOpts.InstrProfileInput); + if (!CodeGenOpts.InstrProfileInput.empty()) { + if (llvm::error_code EC = llvm::IndexedInstrProfReader::create( + CodeGenOpts.InstrProfileInput, PGOReader)) { + unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, + "Could not read profile: %0"); + getDiags().Report(DiagID) << EC.message(); + } + } } CodeGenModule::~CodeGenModule() { @@ -286,7 +293,7 @@ void CodeGenModule::Release() { if (getCodeGenOpts().ProfileInstrGenerate) if (llvm::Function *PGOInit = CodeGenPGO::emitInitialization(*this)) AddGlobalCtor(PGOInit, 0); - if (PGOData && PGOStats.isOutOfDate()) + if (PGOReader && PGOStats.isOutOfDate()) getDiags().Report(diag::warn_profile_data_out_of_date) << PGOStats.Visited << PGOStats.Missing << PGOStats.Mismatched; EmitCtorList(GlobalCtors, "llvm.global_ctors"); |