From c912e4c787ae01a34fa48576e099fcb5950dd828 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 26 Jun 2014 01:45:07 +0000 Subject: CodeGen: Improve warnings about uninstrumented files when profiling Improve the warning when building with -fprofile-instr-use and a file appears not to have been profiled at all. This keys on whether a function is defined in the main file or not to avoid false negatives when one includes a header with functions that have been profiled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211760 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index f1b899f49f..d172b45c68 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -314,6 +314,19 @@ void CodeGenModule::clear() { DeferredDeclsToEmit.clear(); } +void InstrProfStats::reportDiagnostics(DiagnosticsEngine &Diags, + StringRef MainFile) { + if (!hasDiagnostics()) + return; + if (VisitedInMainFile > 0 && VisitedInMainFile == MissingInMainFile) { + if (MainFile.empty()) + MainFile = ""; + Diags.Report(diag::warn_profile_data_unprofiled) << MainFile; + } else + Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing + << Mismatched; +} + void CodeGenModule::Release() { EmitDeferred(); applyReplacements(); @@ -327,9 +340,8 @@ void CodeGenModule::Release() { if (getCodeGenOpts().ProfileInstrGenerate) if (llvm::Function *PGOInit = CodeGenPGO::emitInitialization(*this)) AddGlobalCtor(PGOInit, 0); - if (PGOReader && PGOStats.isOutOfDate()) - getDiags().Report(diag::warn_profile_data_out_of_date) - << PGOStats.Visited << PGOStats.Missing << PGOStats.Mismatched; + if (PGOReader && PGOStats.hasDiagnostics()) + PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName); EmitCtorList(GlobalCtors, "llvm.global_ctors"); EmitCtorList(GlobalDtors, "llvm.global_dtors"); EmitGlobalAnnotations(); -- cgit v1.2.3