[PATCH] D147297: [AutoFDO]Merge called target in body samples
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 23:27:11 PDT 2023
mingmingl updated this revision to Diff 509916.
mingmingl edited the summary of this revision.
mingmingl added a reviewer: wlei.
mingmingl added a comment.
add test case (and minor change to use 'try_emplace' that does nothing if key presents)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147297/new/
https://reviews.llvm.org/D147297
Files:
llvm/include/llvm/ProfileData/SampleProf.h
llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext
llvm/test/tools/llvm-profdata/sample-flatten-profile.test
Index: llvm/test/tools/llvm-profdata/sample-flatten-profile.test
===================================================================
--- llvm/test/tools/llvm-profdata/sample-flatten-profile.test
+++ llvm/test/tools/llvm-profdata/sample-flatten-profile.test
@@ -7,6 +7,7 @@
; CHECK:baz:169:10
; CHECK-NEXT: 1: 10
; CHECK-NEXT: 3: 20
+; CHECK-NEXT: 4: 21 corge:10 quux:6 qux:5
; CHECK-NEXT: 5: 20 foo:20
; CHECK-NEXT: 6: 2 bar:2
; CHECK-NEXT: 10: 1
Index: llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext
===================================================================
--- llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext
+++ llvm/test/tools/llvm-profdata/Inputs/sample-flatten-profile.proftext
@@ -1,6 +1,7 @@
baz:160:10
1: 10
3: 20
+ 4: 21 qux:5 quux:6 corge:10
5: foo:30
1: 20
3: bar:10
Index: llvm/include/llvm/ProfileData/SampleProf.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProf.h
+++ llvm/include/llvm/ProfileData/SampleProf.h
@@ -1342,7 +1342,7 @@
// To retain the context, checksum, attributes of the original profile, make
// a copy of it if no profile is found.
SampleContext &Context = FS.getContext();
- auto Ret = OutputProfiles.emplace(Context, FS);
+ auto Ret = OutputProfiles.try_emplace(Context, FS);
FunctionSamples &Profile = Ret.first->second;
if (Ret.second) {
// When it's the copy of the old profile, just clear all the inlinees'
@@ -1351,9 +1351,14 @@
// We recompute TotalSamples later, so here set to zero.
Profile.setTotalSamples(0);
} else {
- for (const auto &Line : FS.getBodySamples()) {
- Profile.addBodySamples(Line.first.LineOffset, Line.first.Discriminator,
- Line.second.getSamples());
+ for (const auto &[DI, SampleRecord] : FS.getBodySamples()) {
+ Profile.addBodySamples(DI.LineOffset, DI.Discriminator,
+ SampleRecord.getSamples());
+ for (const auto &[CalledTarget, CallTargetSamples] :
+ SampleRecord.getCallTargets()) {
+ Profile.addCalledTargetSamples(DI.LineOffset, DI.Discriminator,
+ CalledTarget, CallTargetSamples);
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147297.509916.patch
Type: text/x-patch
Size: 2333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230331/da160f70/attachment.bin>
More information about the llvm-commits
mailing list