[llvm] [aarch64] XOR the frame pointer with the stack cookie when protecting the stack (PR #161114)
Omair Javaid via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 05:16:07 PDT 2025
omjavaid wrote:
Hi @PanTao2 thanks for writing this patch. I have general comment first as I think we need some further consideration before going ahead with this change.
On Windows MSVC does this a bit differently on AArch64 vs x64. MSVC uses push pop helpers for /GS checks on AArch64 while on x64 it just inlines the checks and calls security_check_cookie at the end.
Also note MSVC on AArch64 mixes the cookie using sub (sp - cookie) but x64 uses xor (cookie ^ rsp) both do the same job but with diff tradeoffs. XOR is smaller and reversible and sub fits better with overall Arm's stack arithmetic. So if the goal here is to exactly mimic MSVC behavior maybe worth thinking which one is closer or better for LLVM side.... maybe just match the semantics not the exact instr choice what do you think?
https://github.com/llvm/llvm-project/pull/161114
More information about the llvm-commits
mailing list