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

Pan Tao via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 19:19:54 PST 2025


================
@@ -2275,6 +2275,14 @@ bool AArch64InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
           .addGlobalAddress(GV, 0, LoFlags)
           .addMemOperand(*MI.memoperands_begin());
     }
+    if (Subtarget.getTargetTriple().isOSMSVCRT() &&
+        !Subtarget.getTargetLowering()
+             ->getTargetMachine()
+             .Options.EnableGlobalISel) {
----------------
PanTao2 wrote:

Yes. Without the EnableGlobalISel check here, the test https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-stack-protector-windows.ll#L2 crash.
I added a simple comment.
Yes. I have moved this outside the if statement.
The eor instruction in the failure BB can not be added in AArch64InstrInfo::expandPostRAPseudo. Therefor, I have modified the existing interface emitStackGuardXorFP to add the eor instruction.
Could you please further review it?

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


More information about the llvm-commits mailing list