[llvm] f15a854 - [llvm-profgen] Truncate the context with zero probe ID
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 30 16:29:59 PST 2021
Author: wlei
Date: 2021-11-30T16:21:25-08:00
New Revision: f15a8545672a643f2a3e0a9ad7d1958470ee488d
URL: https://github.com/llvm/llvm-project/commit/f15a8545672a643f2a3e0a9ad7d1958470ee488d
DIFF: https://github.com/llvm/llvm-project/commit/f15a8545672a643f2a3e0a9ad7d1958470ee488d.diff
LOG: [llvm-profgen] Truncate the context with zero probe ID
Due to the debug info merging, there may have some contexts with zero probe id, we should truncate the context to avoid misleading pre-inliner.
Reviewed By: hoy, wenlei
Differential Revision: https://reviews.llvm.org/D114284
Added:
Modified:
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index 7d28bda1d723..0b90352bc445 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -842,12 +842,12 @@ void CSProfileGenerator::populateBodySamplesWithProbes(
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);
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h
index a28ba82a57e8..3d32cba874b5 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.h
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -476,7 +476,13 @@ class ProfiledBinary {
SmallVector<MCPseduoProbeFrameLocation, 16> ProbeInlineContext;
ProbeDecoder.getInlineContextForProbe(Probe, ProbeInlineContext,
IncludeLeaf);
- for (auto &Callsite : ProbeInlineContext) {
+ for (uint32_t I = 0; I < ProbeInlineContext.size(); I++) {
+ auto &Callsite = ProbeInlineContext[I];
+ // Clear the current context for an unknown probe.
+ if (Callsite.second == 0 && I != ProbeInlineContext.size() - 1) {
+ InlineContextStack.clear();
+ continue;
+ }
InlineContextStack.emplace_back(Callsite.first,
LineLocation(Callsite.second, 0));
}
More information about the llvm-commits
mailing list