[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 06:34:49 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:

Sure, I've removed the `hasStackHazardSlotIndex()` check (and added a little more of an explanation in the comments). I don't think the `hasStackHazardSlotIndex()` check was necessary for correctness, I just was not sure this check should run in the normal case.

https://github.com/llvm/llvm-project/pull/118091


More information about the llvm-commits mailing list