[PATCH] D114284: [llvm-profgen] Truncate the context with zero probe ID
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 14:50:18 PST 2021
wlei updated this revision to Diff 388637.
wlei added a comment.
Updating D114284 <https://reviews.llvm.org/D114284>: [llvm-profgen] Truncate the context with zero probe ID
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114284/new/
https://reviews.llvm.org/D114284
Files:
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
@@ -760,12 +760,12 @@
FunctionProfile.addHeadSamples(Count);
// Look up for the caller's function profile
const auto *InlinerDesc = Binary->getInlinerDescForProbe(Probe);
- if (InlinerDesc != nullptr) {
+ SampleContextFrames CalleeContextId =
+ FunctionProfile.getContext().getContextFrames();
+ if (InlinerDesc != nullptr && CalleeContextId.size() > 1) {
// Since the context id will be compressed, we have to use callee's
// context id to infer caller's context id to ensure they share the
// same context prefix.
- SampleContextFrames CalleeContextId =
- FunctionProfile.getContext().getContextFrames();
SampleContextFrameVector CallerContextId;
SampleContextFrame &&CallerLeafFrameLoc =
getCallerContext(CalleeContextId, CallerContextId);
@@ -825,6 +825,20 @@
SampleContextFrameVector NewContextStack(ContextStack.begin(),
ContextStack.end());
Binary->getInlineContextForProbe(LeafProbe, NewContextStack, true);
+
+ int ZeroProbeIdx = -1;
+ for (uint32_t I = 0; I < NewContextStack.size() - 1; I++) {
+ auto &Callsite = NewContextStack[I];
+ // Ignore the context if the probe of the callsite is zero.
+ if (Callsite.Location.LineOffset == 0)
+ ZeroProbeIdx = I;
+ }
+ if (ZeroProbeIdx != -1) {
+ std::copy(NewContextStack.begin() + ZeroProbeIdx + 1, NewContextStack.end(),
+ NewContextStack.begin());
+ NewContextStack.resize(NewContextStack.size() - ZeroProbeIdx - 1);
+ }
+
// For leaf inlined context with the top frame, we should strip off the top
// frame's probe id, like:
// Inlined stack: [foo:1, bar:2], the ContextId will be "foo:1 @ bar"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114284.388637.patch
Type: text/x-patch
Size: 1990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/b5f9a57c/attachment.bin>
More information about the llvm-commits
mailing list