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
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user