[PATCH] D157061: [SampleProfile] Potential use after move in SampleProfileLoader::promoteMergeNotInlinedContextSamples
William Junda Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 12 01:24:08 PDT 2023
huangjd updated this revision to Diff 549583.
huangjd added a comment.
Rewrite patch, use a much cleaner approach by separating the sample profile map
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157061/new/
https://reviews.llvm.org/D157061
Files:
llvm/include/llvm/ProfileData/SampleProfReader.h
Index: llvm/include/llvm/ProfileData/SampleProfReader.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProfReader.h
+++ llvm/include/llvm/ProfileData/SampleProfReader.h
@@ -413,31 +413,38 @@
std::string FGUID;
StringRef CanonName = FunctionSamples::getCanonicalFnName(F);
CanonName = getRepInFormat(CanonName, useMD5(), FGUID);
- auto It = Profiles.find(CanonName);
- if (It != Profiles.end())
- return &It->second;
+ for (SampleProfileMap *ProfileMap : {&Profiles, &OutlineFunctionSamples}) {
+ auto It = ProfileMap->find(CanonName);
+ if (It != ProfileMap->end())
+ return &It->second;
+ }
if (!FGUID.empty()) {
assert(useMD5() && "New name should only be generated for md5 profile");
CanonName = *MD5NameBuffer.insert(FGUID).first;
}
- return &Profiles[CanonName];
+ return &OutlineFunctionSamples[CanonName];
}
/// Return the samples collected for function \p F.
virtual FunctionSamples *getSamplesFor(StringRef Fname) {
std::string FGUID;
Fname = getRepInFormat(Fname, useMD5(), FGUID);
- auto It = Profiles.find(Fname);
- if (It != Profiles.end())
- return &It->second;
+ for (SampleProfileMap *ProfileMap : {&Profiles, &OutlineFunctionSamples}) {
+ auto It = ProfileMap->find(Fname);
+ if (It != ProfileMap->end())
+ return &It->second;
+ }
if (Remapper) {
if (auto NameInProfile = Remapper->lookUpNameInProfile(Fname)) {
- auto It = Profiles.find(*NameInProfile);
- if (It != Profiles.end())
- return &It->second;
+ for (SampleProfileMap *ProfileMap : {&Profiles, &OutlineFunctionSamples}) {
+ auto It = ProfileMap->find(*NameInProfile);
+ if (It != ProfileMap->end())
+ return &It->second;
+ }
}
}
+
return nullptr;
}
@@ -520,6 +527,11 @@
/// to their corresponding profiles.
SampleProfileMap Profiles;
+ /// Synthetic function samples created by SampleProfileLoader when inlined
+ /// callsites are duplicated as non-inlined callsites. They are added to here
+ /// instead of the original profiles to prevent potential rehashing.
+ SampleProfileMap OutlineFunctionSamples;
+
/// LLVM context used to emit diagnostics.
LLVMContext &Ctx;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157061.549583.patch
Type: text/x-patch
Size: 2363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230812/b321367b/attachment.bin>
More information about the llvm-commits
mailing list