Skip to content

Commit d32fe95

Browse files
authored
[BOLT][AArch64] Do not relax ADR referencing the same fragment (#108673)
ADR can reference a secondary entry point in the same function. If that's the case, we can skip relaxing the instruction when it is in the same fragment as its target. Fixes #108290
1 parent 1825cf2 commit d32fe95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5959
// Don't relax adr if it points to the same function and it is not split
6060
// and BF initial size is < 1MB.
6161
const unsigned OneMB = 0x100000;
62-
if (!BF.isSplit() && BF.getSize() < OneMB) {
62+
if (BF.getSize() < OneMB) {
6363
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
64-
if (TargetBF && TargetBF == &BF)
64+
if (TargetBF == &BF && !BF.isSplit())
6565
continue;
66+
// No relaxation needed if ADR references a basic block in the same
67+
// fragment.
68+
if (BinaryBasicBlock *TargetBB = BF.getBasicBlockForLabel(Symbol))
69+
if (BB.getFragmentNum() == TargetBB->getFragmentNum())
70+
continue;
6671
}
6772

6873
MCPhysReg Reg;

0 commit comments

Comments
 (0)