[llvm] RuntimeLibcalls: Fix stacksmash on arm64ec (PR #152116)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 03:23:20 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Fix after 5478da9

---
Full diff: https://github.com/llvm/llvm-project/pull/152116.diff


2 Files Affected:

- (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+4-1) 
- (added) llvm/test/CodeGen/AArch64/stacksmash-arm64ec.ll (+16) 


``````````diff
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 4905c8a420dcc..5d1015e585e47 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1247,9 +1247,12 @@ defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
   }
 }
 
+def arm64ec___stack_chk_fail : DuplicateLibcallImplWithPrefix<__stack_chk_fail, "#">;
+
 def WindowsARM64ECSystemLibrary
     : SystemRuntimeLibrary<isWindowsArm64EC,
-                           (add WinArm64ECDefaultRuntimeLibcallImpls)>;
+                           (add WinArm64ECDefaultRuntimeLibcallImpls,
+                                arm64ec___stack_chk_fail)>;
 
 //===----------------------------------------------------------------------===//
 // AMDGPU Runtime Libcalls
diff --git a/llvm/test/CodeGen/AArch64/stacksmash-arm64ec.ll b/llvm/test/CodeGen/AArch64/stacksmash-arm64ec.ll
new file mode 100644
index 0000000000000..0960133d7d054
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/stacksmash-arm64ec.ll
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=arm64ec-unknown-windows-gnu < %s | FileCheck %s
+
+; CHECK-LABEL: func = "#func"
+; CHECK: bl "#other"
+; CHECK: bl "#__stack_chk_fail"
+define void @func() #0 {
+entry:
+  %buf = alloca [10 x i8], align 1
+  call void @other(ptr %buf) #1
+  ret void
+}
+
+declare void @other(ptr) #1
+
+attributes #0 = { nounwind sspstrong }
+attributes #1 = { nounwind }

``````````

</details>


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


More information about the llvm-commits mailing list