[llvm] [BOLT][AArch64] Do not relax ADR referencing the same fragment (PR #108673)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 20:13:01 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Maksim Panchenko (maksfb)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/108673.diff
1 Files Affected:
- (modified) bolt/lib/Passes/ADRRelaxationPass.cpp (+7-2)
``````````diff
diff --git a/bolt/lib/Passes/ADRRelaxationPass.cpp b/bolt/lib/Passes/ADRRelaxationPass.cpp
index 24fddbc764cbe7..256034a841c706 100644
--- a/bolt/lib/Passes/ADRRelaxationPass.cpp
+++ b/bolt/lib/Passes/ADRRelaxationPass.cpp
@@ -59,10 +59,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
// Don't relax adr if it points to the same function and it is not split
// and BF initial size is < 1MB.
const unsigned OneMB = 0x100000;
- if (!BF.isSplit() && BF.getSize() < OneMB) {
+ if (BF.getSize() < OneMB) {
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
- if (TargetBF && TargetBF == &BF)
+ if (TargetBF == &BF && !BF.isSplit())
continue;
+ // No relaxation needed if ADR references a basic block in the same
+ // fragment.
+ if (BinaryBasicBlock *TargetBB = BF.getBasicBlockForLabel(Symbol))
+ if (BB.getFragmentNum() == TargetBB->getFragmentNum())
+ continue;
}
MCPhysReg Reg;
``````````
</details>
https://github.com/llvm/llvm-project/pull/108673
More information about the llvm-commits
mailing list