[PATCH] D95009: [llvm-profgen][NFC] Fix the incorrect computation of callsite sample count
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 16:20:58 PST 2021
wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind.
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/D95009
Files:
llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
llvm/tools/llvm-profgen/ProfileGenerator.cpp
Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -239,11 +239,9 @@
// Record called target sample and its count
const FrameLocation &LeafLoc = Binary->getInlineLeafFrameLoc(SourceOffset);
-
FunctionProfile.addCalledTargetSamples(LeafLoc.second.LineOffset,
LeafLoc.second.Discriminator,
CalleeName, Count);
- FunctionProfile.addTotalSamples(Count);
// Record head sample for called target(callee)
// TODO: Cleanup ' @ '
@@ -274,6 +272,16 @@
return LeafFrameLoc;
}
+static void accumulateBodySamples(FunctionSamples &FunctionProfile,
+ const FrameLocation &LeafLoc,
+ uint64_t Count) {
+ if (LeafLoc.second.LineOffset & 0x80000000)
+ return;
+ FunctionProfile.addBodySamples(LeafLoc.second.LineOffset,
+ LeafLoc.second.Discriminator, Count);
+ FunctionProfile.addTotalSamples(Count);
+}
+
void CSProfileGenerator::populateInferredFunctionSamples() {
for (const auto &Item : ProfileMap) {
const StringRef CalleeContext = Item.first();
@@ -313,6 +321,8 @@
EstimatedCallCount);
updateBodySamplesforFunctionProfile(CallerProfile, CallerLeafFrameLoc,
EstimatedCallCount);
+ accumulateBodySamples(CallerProfile, CallerLeafFrameLoc,
+ EstimatedCallCount);
}
}
Index: llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
===================================================================
--- llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
+++ llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
@@ -7,7 +7,7 @@
; CHECK: 2: 2
; CHECK: 4: 1
; CHECK: 5: 3
-; CHECK:[main:1 @ foo]:9:0
+; CHECK:[main:1 @ foo]:6:0
; CHECK: 2: 3
; CHECK: 3: 3 bar:3
Index: llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
===================================================================
--- llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
+++ llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
@@ -1,10 +1,10 @@
; RUN: llvm-profgen --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --show-unwinder-output | FileCheck %s --check-prefix=CHECK-UNWINDER
; RUN: FileCheck %s --input-file %t
-; CHECK:[main:1 @ foo]:44:0
+; CHECK:[main:1 @ foo]:58:0
; CHECK: 2.2: 14
; CHECK: 3: 15
-; CHECK: 3.2: 14 bar:14
+; CHECK: 3.2: 28 bar:14
; CHECK: 3.4: 1
; CHECK:[main:1 @ foo:3.2 @ bar]:14:0
; CHECK: 1: 14
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95009.317723.patch
Type: text/x-patch
Size: 2759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210120/5ece7638/attachment.bin>
More information about the llvm-commits
mailing list