[llvm] [AArch64] Fix frame-pointer offset with hazard padding (PR #118091)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 05:58:12 PST 2024
================
@@ -3167,11 +3167,21 @@ static void computeCalleeSaveRegisterPairs(
(RPI.isScalable() && RPI.Offset >= -256 && RPI.Offset <= 255)) &&
"Offset out of bounds for LDP/STP immediate");
+ auto isFrameRecord = [&] {
+ if (RPI.isPaired())
+ return IsWindows ? RPI.Reg1 == AArch64::FP && RPI.Reg2 == AArch64::LR
+ : RPI.Reg1 == AArch64::LR && RPI.Reg2 == AArch64::FP;
+ // -aarch64-stack-hazard-size=<val> disables register pairing, so look
+ // for the frame record as two unpaired registers.
+ if (AFI->hasStackHazardSlotIndex())
+ return i > 0 && RPI.Reg1 == AArch64::FP &&
+ CSI[i - 1].getReg() == AArch64::LR;
----------------
MacDue wrote:
> Also, as it stands, your code would need updating to make this work for windows, for example.
I did check this on Windows and it's correct (probably should add a test :sweat_smile:)
On Linux this matches current reg = FP, previous reg = LR, on Windows it matches current reg = FP, next reg = LR, which works out as the correct offset in both cases.
https://github.com/llvm/llvm-project/pull/118091
More information about the llvm-commits
mailing list