This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Fix trampoline code for shared libraries and PIEs
ClosedPublic

Authored by maksfb on Jun 27 2022, 9:02 PM.

Details

Summary

When SplitFunctions pass adds a trampoline code for exceptions landing
pads, it may increase the size of the hot code past an acceptable
threshold and trigger the revert of the splitting.

However, if createEHTrampolines() added new blocks to the CFG and
modified invoke instructions, simply restoring the original block layout
will not suffice. In such case, modify the original layout by merging in
trampoline blocks right before their matching targets. As a result, the
number of blocks will increase, but the number of instructions will stay
the same.

Diff Detail

Event Timeline

maksfb created this revision.Jun 27 2022, 9:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 9:02 PM
maksfb requested review of this revision.Jun 27 2022, 9:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 9:02 PM
maksfb updated this revision to Diff 440757.Jun 28 2022, 1:44 PM

std::unordered_map -> DenseMap.

maksfb updated this revision to Diff 440800.Jun 28 2022, 4:03 PM

Update test case.

rafauler accepted this revision.Jun 28 2022, 4:31 PM

LGTM

bolt/test/runtime/X86/pie-exceptions-failed-split.test
32–34

not sure what's the intent of using check-dag here instead of regular CHECK:

This revision is now accepted and ready to land.Jun 28 2022, 4:31 PM
maksfb added inline comments.Jun 28 2022, 5:27 PM
bolt/test/runtime/X86/pie-exceptions-failed-split.test
32–34

I want to check that __cxa_begin_catch is in the same (successor) block. Maybe there's a better way? With CHECK-DAG it makes sure there's no another block (with "Exec Count") in between.

This revision was automatically updated to reflect the committed changes.