[llvm] [BOLT] Avoid EH trampolines for PIEs/DSOs (PR #117106)
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 13:24:28 PST 2024
================
@@ -901,8 +901,42 @@ void SplitFunctions::splitFunction(BinaryFunction &BF, SplitStrategy &S) {
// have to be placed in the same fragment. When we split them, create
// trampoline landing pads that will redirect the execution to real LPs.
TrampolineSetType Trampolines;
- if (!BC.HasFixedLoadAddress && BF.hasEHRanges() && BF.isSplit())
- Trampolines = createEHTrampolines(BF);
+ if (!BC.HasFixedLoadAddress && BF.hasEHRanges() && BF.isSplit()) {
+ // If all landing pads for this fragment are grouped in one (potentially
+ // different) fragment, we can set LPStart to the start of that fragment
+ // and avoid trampoline code.
+ bool NeedsTrampolines = false;
+ for (FunctionFragment &FF : BF.getLayout().fragments()) {
+ // Vector of fragments that contain landing pads for this fragment.
+ SmallVector<FragmentNum, 4> LandingPadFragments;
+ for (const BinaryBasicBlock *BB : FF)
+ for (const BinaryBasicBlock *LPB : BB->landing_pads())
+ LandingPadFragments.push_back(LPB->getFragmentNum());
+
+ llvm::sort(LandingPadFragments);
----------------
dcci wrote:
Would be useful to add a comment on why this sorting is needed
https://github.com/llvm/llvm-project/pull/117106
More information about the llvm-commits
mailing list