[llvm] [aarch64] Mix the frame pointer with the stack cookie when protecting the stack (PR #197346)

Pan Tao via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 22:01:37 PDT 2026


================
@@ -570,6 +570,16 @@ bool AArch64FrameLowering::hasFPImpl(const MachineFunction &MF) const {
   // funclets.
   if (MF.hasEHFunclets())
     return true;
+
+  // Force FP for functions with stack guards on MSVCRT.
+  // The cookie mixing uses FP to ensure consistent addressing even with
+  // dynamic stack allocation (e.g., _alloca).
+  if (MFI.hasStackProtectorIndex()) {
+    const auto &Subtarget = MF.getSubtarget<AArch64Subtarget>();
+    if (Subtarget.getTargetTriple().isOSMSVCRT())
----------------
PanTao2 wrote:

Yes. I replaced it with useStackGuardMixFP(). Could you please further review?

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


More information about the llvm-commits mailing list