diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-06-26 01:45:07 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-06-26 01:45:07 +0000 |
commit | 40b8ba1496e54066b69c181b40d37ec1a823862b (patch) | |
tree | 0803ea1ed0709c089a204898ea6fafbd4c3a1ec1 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 2710d01ce2394637070472f0355138f162315ec1 (diff) | |
download | llvm-40b8ba1496e54066b69c181b40d37ec1a823862b.zip llvm-40b8ba1496e54066b69c181b40d37ec1a823862b.tar.gz llvm-40b8ba1496e54066b69c181b40d37ec1a823862b.tar.bz2 |
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.
llvm-svn: 211760
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f1b899f..d172b45 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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 = "<stdin>"; + 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(); |