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.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.h') diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 6cb4fc17c5..d96b34eee6 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -218,12 +218,36 @@ struct ARCEntrypoints { }; /// This class records statistics on instrumentation based profiling. -struct InstrProfStats { - InstrProfStats() : Visited(0), Missing(0), Mismatched(0) {} - bool isOutOfDate() { return Missing || Mismatched; } +class InstrProfStats { + uint32_t VisitedInMainFile; + uint32_t MissingInMainFile; uint32_t Visited; uint32_t Missing; uint32_t Mismatched; + +public: + InstrProfStats() + : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0), + Mismatched(0) {} + /// Record that we've visited a function and whether or not that function was + /// in the main source file. + void addVisited(bool MainFile) { + if (MainFile) + ++VisitedInMainFile; + ++Visited; + } + /// Record that a function we've visited has no profile data. + void addMissing(bool MainFile) { + if (MainFile) + ++MissingInMainFile; + ++Missing; + } + /// Record that a function we've visited has mismatched profile data. + void addMismatched(bool MainFile) { ++Mismatched; } + /// Whether or not the stats we've gathered indicate any potential problems. + bool hasDiagnostics() { return Missing || Mismatched; } + /// Report potential problems we've found to \c Diags. + void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile); }; /// This class organizes the cross-function state that is used while generating -- cgit v1.2.3