From ff9a0582673a6f1e73d5ac60d03e43fb7038ea50 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 12 Mar 2014 20:53:16 +0000 Subject: CodeGen: Use a binary format for instrumentation based profiling This updates CodeGenPGO to use the ProfileDataReader introduced to llvm in r203703 and the new API for writing out the profile introduced to compiler-rt in r203710. llvm-svn: 203711 --- clang/lib/CodeGen/CodeGenModule.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4f040e2..484c4ed 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/Profile/ProfileDataReader.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" @@ -77,7 +78,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), @@ -133,8 +134,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::ProfileDataReader::create( + CodeGenOpts.InstrProfileInput, PGOReader)) { + unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, + "Could not read profile: %0"); + getDiags().Report(DiagID) << EC.message(); + } + } } CodeGenModule::~CodeGenModule() { -- cgit v1.1