diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -210,12 +210,11 @@ // Command line option to enable/disable the warning about a hash mismatch in // the profile data for Comdat functions, which often turns out to be false // positive due to the pre-instrumentation inline. -static cl::opt - NoPGOWarnMismatchComdat("no-pgo-warn-mismatch-comdat", cl::init(true), - cl::Hidden, - cl::desc("The option is used to turn on/off " - "warnings about hash mismatch for comdat " - "functions.")); +static cl::opt NoPGOWarnMismatchComdatWeak( + "no-pgo-warn-mismatch-comdat-weak", cl::init(true), cl::Hidden, + cl::desc("The option is used to turn on/off " + "warnings about hash mismatch for comdat " + "or weak functions.")); // Command line option to enable/disable select instruction instrumentation. static cl::opt @@ -287,6 +286,11 @@ cl::desc("Set the threshold for pgo-verify-bfi: skip the counts whose " "profile count value is below.")); +static cl::opt PGOTraceFuncHash( + "pgo-trace-func-hash", cl::init("-"), cl::Hidden, + cl::value_desc("function name"), + cl::desc("Trace the hash of the function with this name.")); + namespace llvm { // Command line option to turn on CFG dot dump after profile annotation. // Defined in Analysis/BlockFrequencyInfo.cpp: -pgo-view-counts @@ -630,6 +634,10 @@ << ", High32 CRC = " << JCH.getCRC()); } LLVM_DEBUG(dbgs() << ", Hash = " << FunctionHash << "\n";); + + if (PGOTraceFuncHash != "-" && F.getName().contains(PGOTraceFuncHash)) + dbgs() << "Funcname=" << F.getName() << ", Hash=" << FunctionHash + << " in building " << F.getParent()->getSourceFileName() << "\n"; } // Check if we can safely rename this Comdat function. @@ -1233,10 +1241,11 @@ IsCS ? NumOfCSPGOMismatch++ : NumOfPGOMismatch++; SkipWarning = NoPGOWarnMismatch || - (NoPGOWarnMismatchComdat && - (F.hasComdat() || + (NoPGOWarnMismatchComdatWeak && + (F.hasComdat() || F.getLinkage() == GlobalValue::WeakAnyLinkage || F.getLinkage() == GlobalValue::AvailableExternallyLinkage)); - LLVM_DEBUG(dbgs() << "hash mismatch (skip=" << SkipWarning << ")"); + LLVM_DEBUG(dbgs() << "hash mismatch (hash= " << FuncInfo.FunctionHash + << " skip=" << SkipWarning << ")"); // Emit function metadata indicating PGO profile mismatch. annotateFunctionWithHashMismatch(F, M->getContext()); }