diff options
author | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2023-08-15 14:46:19 -0700 |
---|---|---|
committer | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2023-08-15 15:28:16 -0700 |
commit | d687caae00469cf8fa47c573d98e9d4a85bc872f (patch) | |
tree | 9722049ee06094e7bea9a1d95d56285b37066bb6 /llvm/tools/llvm-profdata/llvm-profdata.cpp | |
parent | 92d7254a989d106ba63e64d315dbb9397c275671 (diff) | |
download | llvm-d687caae00469cf8fa47c573d98e9d4a85bc872f.zip llvm-d687caae00469cf8fa47c573d98e9d4a85bc872f.tar.gz llvm-d687caae00469cf8fa47c573d98e9d4a85bc872f.tar.bz2 |
[InstrProf] Emit warnings when correlating lightweight profiles
Emit warnings when `InstrProfCorrelator` finds problems with debug info for lightweight instrumentation profile correlation. To prevent excessive printing, only emit the first 5 warnings.
In addition, remove a diagnostic about missing debug info in `InstrProfiling.cpp`. Some compiler-generated functions, e.g., `__clang_call_terminate`, does not emit debug info and will fail a build if `-Werror` is used. This warning is not actionable by the user and I have not seen non-compiler-generated functions fail this test.
Reviewed By: smeenai
Differential Revision: https://reviews.llvm.org/D156006
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 9da5368..d4266fb 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -407,8 +407,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, StringRef DebugInfoFilename, SymbolRemapper *Remapper, StringRef OutputFilename, ProfileFormat OutputFormat, uint64_t TraceReservoirSize, - uint64_t MaxTraceLength, bool OutputSparse, - unsigned NumThreads, FailureMode FailMode, + uint64_t MaxTraceLength, int MaxDbgCorrelationWarnings, + bool OutputSparse, unsigned NumThreads, FailureMode FailMode, const StringRef ProfiledBinary) { if (OutputFormat == PF_Compact_Binary) exitWithError("Compact Binary is deprecated"); @@ -421,7 +421,7 @@ mergeInstrProfile(const WeightedFileVector &Inputs, StringRef DebugInfoFilename, if (auto Err = InstrProfCorrelator::get(DebugInfoFilename).moveInto(Correlator)) exitWithError(std::move(Err), DebugInfoFilename); - if (auto Err = Correlator->correlateProfileData()) + if (auto Err = Correlator->correlateProfileData(MaxDbgCorrelationWarnings)) exitWithError(std::move(Err), DebugInfoFilename); } @@ -1270,6 +1270,11 @@ static int merge_main(int argc, const char *argv[]) { cl::opt<std::string> DebugInfoFilename( "debug-info", cl::init(""), cl::desc("Use the provided debug info to correlate the raw profile.")); + cl::opt<unsigned> MaxDbgCorrelationWarnings( + "max-debug-info-correlation-warnings", + cl::desc("The maximum number of warnings to emit when correlating " + "profile from debug info (0 = no limit)"), + cl::init(5)); cl::opt<std::string> ProfiledBinary( "profiled-binary", cl::init(""), cl::desc("Path to binary from which the profile was collected.")); @@ -1331,8 +1336,8 @@ static int merge_main(int argc, const char *argv[]) { mergeInstrProfile(WeightedInputs, DebugInfoFilename, Remapper.get(), OutputFilename, OutputFormat, TemporalProfTraceReservoirSize, - TemporalProfMaxTraceLength, OutputSparse, NumThreads, - FailureMode, ProfiledBinary); + TemporalProfMaxTraceLength, MaxDbgCorrelationWarnings, + OutputSparse, NumThreads, FailureMode, ProfiledBinary); else mergeSampleProfile(WeightedInputs, Remapper.get(), OutputFilename, OutputFormat, ProfileSymbolListFile, CompressAllSections, @@ -2877,6 +2882,7 @@ static int showMemProfProfile(const std::string &Filename, static int showDebugInfoCorrelation(const std::string &Filename, bool ShowDetailedSummary, bool ShowProfileSymbolList, + int MaxDbgCorrelationWarnings, ShowFormat SFormat, raw_fd_ostream &OS) { if (SFormat == ShowFormat::Json) exitWithError("JSON output is not supported for debug info correlation"); @@ -2884,12 +2890,12 @@ static int showDebugInfoCorrelation(const std::string &Filename, if (auto Err = InstrProfCorrelator::get(Filename).moveInto(Correlator)) exitWithError(std::move(Err), Filename); if (SFormat == ShowFormat::Yaml) { - if (auto Err = Correlator->dumpYaml(OS)) + if (auto Err = Correlator->dumpYaml(MaxDbgCorrelationWarnings, OS)) exitWithError(std::move(Err), Filename); return 0; } - if (auto Err = Correlator->correlateProfileData()) + if (auto Err = Correlator->correlateProfileData(MaxDbgCorrelationWarnings)) exitWithError(std::move(Err), Filename); InstrProfSymtab Symtab; @@ -2989,6 +2995,11 @@ static int show_main(int argc, const char *argv[]) { "debug-info", cl::init(""), cl::desc("Read and extract profile metadata from debug info and show " "the functions it found.")); + cl::opt<unsigned> MaxDbgCorrelationWarnings( + "max-debug-info-correlation-warnings", + cl::desc("The maximum number of warnings to emit when correlating " + "profile from debug info (0 = no limit)"), + cl::init(5)); cl::opt<bool> ShowCovered( "covered", cl::init(false), cl::desc("Show only the functions that have been executed.")); @@ -3022,7 +3033,8 @@ static int show_main(int argc, const char *argv[]) { if (!DebugInfoFilename.empty()) return showDebugInfoCorrelation(DebugInfoFilename, ShowDetailedSummary, - ShowProfileSymbolList, SFormat, OS); + ShowProfileSymbolList, + MaxDbgCorrelationWarnings, SFormat, OS); if (ProfileKind == instr) return showInstrProfile( |