[llvm] [llvm][Support] Add ARM64e support for split stacks (PR #139964)
Michael Spencer via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 14:17:26 PDT 2025
https://github.com/Bigcheese created https://github.com/llvm/llvm-project/pull/139964
ARM64e needs to use the authenticated version of blr for this call as the target function pointer is signed. This also adds the pacibsp/retab pair. This is not strictly required, but is a standard part of the prolog/epilog.
>From 4a79181cb97ae4eb8754857185fc9a59256d6402 Mon Sep 17 00:00:00 2001
From: Michael Spencer <bigcheesegs at gmail.com>
Date: Wed, 14 May 2025 14:13:43 -0700
Subject: [PATCH] [llvm][Support] Add ARM64e support for split stacks
ARM64e needs to use the authenticated version of blr for this call as
the target function pointer is signed. This also adds the
pacibsp/retab pair. This is not strictly required, but is a standard
part of the prolog/epilog.
---
llvm/lib/Support/ProgramStack.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/llvm/lib/Support/ProgramStack.cpp b/llvm/lib/Support/ProgramStack.cpp
index 66f74ff660b20..ce396472126cd 100644
--- a/llvm/lib/Support/ProgramStack.cpp
+++ b/llvm/lib/Support/ProgramStack.cpp
@@ -70,6 +70,9 @@ __asm__ (
".p2align 2\n\t"
"_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_:\n\t"
".cfi_startproc\n\t"
+#if __arm64e__
+ "pacibsp\n\t" // sign x30 using sp
+#endif
"mov x16, sp\n\t"
"sub x0, x0, #0x20\n\t" // subtract space from stack
"stp xzr, x16, [x0, #0x00]\n\t" // save old sp
@@ -81,12 +84,20 @@ __asm__ (
".cfi_offset w29, -16\n\t" // fp
"mov x0, x2\n\t" // Ctx is the only argument
+#if __arm64e__
+ "blraaz x1\n\t" // authenticate x1 then call Fn
+#else
"blr x1\n\t" // call Fn
+#endif
"ldp x29, x30, [sp, #0x10]\n\t" // restore fp, lr
"ldp xzr, x16, [sp, #0x00]\n\t" // load old sp
"mov sp, x16\n\t"
+#if __arm64e__
+ "retab\n\t" // authenticate x30 then return
+#else
"ret\n\t"
+#endif
".cfi_endproc"
);
#endif
More information about the llvm-commits
mailing list