Skip to content

Commit 6206817

Browse files
authored
[BOLT][AArch64] Fix ADR relaxation (#71835)
Currently we have an optimization that if the ADR points to the same function we might skip it's relaxation. But it doesn't take into account that BF might be split, in such situation we still need to relax it. And just in case also relax if the initial BF size is >= 1MB. Fixes #71822
1 parent cf18f14 commit 6206817

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5656
continue;
5757
}
5858

59-
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
60-
if (TargetBF && TargetBF == &BF)
61-
continue;
59+
// Don't relax adr if it points to the same function and it is not split
60+
// and BF initial size is < 1MB.
61+
const unsigned OneMB = 0x100000;
62+
if (!BF.isSplit() && BF.getSize() < OneMB) {
63+
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
64+
if (TargetBF && TargetBF == &BF)
65+
continue;
66+
}
6267

6368
MCPhysReg Reg;
6469
BC.MIB->getADRReg(Inst, Reg);

0 commit comments

Comments
 (0)