This is an archive of the discontinued LLVM Phabricator instance.

[PseudoProbe] Use callee name as callsite identfier for MCDecodedPseudoProbeInlineTree.
ClosedPublic

Authored by hoy on May 25 2022, 4:30 PM.

Details

Summary

The callsite identifier used in pseudo probe encoding and decoding is consisted of a function name and the callsite probe id. For encoding, i.e., MCPseudoProbeInlineTree, the function name is callee function name. However for decoding, i.e., MCDecodedPseudoProbeInlineTree, the caller function name is used actually. This results in multiple callees that are inlined at the same callsite, likely via indirect call promotion, sharing the same decoded inline frame. While it is not a problem for profile generation, it confuses probe re-encoding in Bolt.

In Bolt, we decode pseudo probes first and build MCDecodedPseudoProbeInlineTree. The decoded tree is used for final re-encoding. Here comes the problem. Two inlinees from the same callsite share the same decoded inline frame. During re-encoding, the frame name (whatever inlinee comes first) will be used and encoded in the bolted binary. This will cause wrong inline contexts in the profile generated on the bolted binary.

The fix is a no-op to pre-bolt profile generation. Some of the bolt tests are not yet upstreamed, thus I'm not adding a bolt test here.

Diff Detail

Event Timeline

hoy created this revision.May 25 2022, 4:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 4:30 PM
hoy requested review of this revision.May 25 2022, 4:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 4:30 PM
hoy edited the summary of this revision. (Show Details)May 25 2022, 4:35 PM
hoy added reviewers: wenlei, wlei.
wenlei added inline comments.Jun 8 2022, 12:29 AM
llvm/lib/MC/MCPseudoProbe.cpp
576

is std::get<0>(xx->ISite) equivalent to xx->Parent->Guid?

hoy added inline comments.Jun 8 2022, 10:21 AM
llvm/lib/MC/MCPseudoProbe.cpp
576

They were equivalent, but they are not with this patch. Note that we are changing std::get<0>(xx->ISite) to the inlinee's Guid at line 419 above.

wenlei accepted this revision.Jun 8 2022, 10:27 AM

lgtm, thanks

llvm/lib/MC/MCPseudoProbe.cpp
576

Got it. Can you update the comment below to make it explicit that the GUID is callee's.

// An inline frame has the form <Guid, ProbeID>
using InlineSite = std::tuple<uint64_t, uint32_t>;

This revision is now accepted and ready to land.Jun 8 2022, 10:27 AM
hoy updated this revision to Diff 435246.Jun 8 2022, 10:38 AM

Updating D126434: [PseudoProbe] Use callee name as callsite identfier for MCDecodedPseudoProbeInlineTree.

llvm/lib/MC/MCPseudoProbe.cpp
576

Good point, done.

This revision was landed with ongoing or failed builds.Jun 8 2022, 10:54 AM
This revision was automatically updated to reflect the committed changes.