[PATCH] D156715: [CSSPGO] Fix issues with post-link function checksum check
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 09:48:01 PDT 2023
wlei created this revision.
Herald added subscribers: ormris, hoy, wenlei, hiraditya.
Herald added a project: All.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156715
Files:
llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
llvm/lib/Transforms/IPO/SampleProfile.cpp
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1819,7 +1819,14 @@
bool Changed = false;
if (FunctionSamples::ProfileIsProbeBased) {
- if (!ProbeManager->profileIsValid(F, *Samples)) {
+ const auto *FuncDesc = ProbeManager->getDesc(F);
+ if (!FuncDesc) {
+ LLVM_DEBUG(dbgs() << "There is no probe_desc for " << F.getName()
+ << " or it's an external function."
+ << "\n");
+ return false;
+ }
+ if (!ProbeManager->profileIsHashMismatched(*FuncDesc, *Samples)) {
LLVM_DEBUG(
dbgs() << "Profile is invalid due to CFG mismatch for Function "
<< F.getName() << "\n");
@@ -2268,7 +2275,8 @@
uint64_t Count = FS.getTotalSamples();
TotalFuncHashSamples += Count;
TotalProfiledFunc++;
- if (!ProbeManager->profileIsValid(F, FS)) {
+ const auto *FuncDesc = ProbeManager->getDesc(F);
+ if (FuncDesc && ProbeManager->profileIsHashMismatched(*FuncDesc, FS)) {
MismatchedFuncHashSamples += Count;
NumMismatchedFuncHash++;
IsFuncHashMismatch = true;
Index: llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
+++ llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
@@ -87,12 +87,6 @@
class PseudoProbeManager {
DenseMap<uint64_t, PseudoProbeDescriptor> GUIDToProbeDescMap;
- const PseudoProbeDescriptor *getDesc(const Function &F) const {
- auto I = GUIDToProbeDescMap.find(
- Function::getGUID(FunctionSamples::getCanonicalFnName(F)));
- return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
- }
-
public:
PseudoProbeManager(const Module &M) {
if (NamedMDNode *FuncInfo =
@@ -108,10 +102,21 @@
}
}
+ const PseudoProbeDescriptor *getDesc(const Function &F) const {
+ auto I = GUIDToProbeDescMap.find(
+ Function::getGUID(FunctionSamples::getCanonicalFnName(F)));
+ return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
+ }
+
bool moduleIsProbed(const Module &M) const {
return M.getNamedMetadata(PseudoProbeDescMetadataName);
}
+ bool profileIsHashMismatched(const PseudoProbeDescriptor &FuncDesc,
+ const FunctionSamples &Samples) const {
+ return FuncDesc.getFunctionHash() != Samples.getFunctionHash();
+ }
+
bool profileIsValid(const Function &F, const FunctionSamples &Samples) const {
const auto *Desc = getDesc(F);
if (!Desc) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156715.545717.patch
Type: text/x-patch
Size: 2739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230731/021bedf4/attachment.bin>
More information about the llvm-commits
mailing list