Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Aug 5, 2025

Fix after 5478da9

Copy link
Contributor Author

arsenm commented Aug 5, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Aug 5, 2025

@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-backend-aarch64

Author: Matt Arsenault (arsenm)

Changes

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 --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 }

@arsenm arsenm marked this pull request as ready for review August 5, 2025 10:23
@llvmbot llvmbot added the llvm:ir label Aug 5, 2025
Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick fix!

@arsenm arsenm merged commit 0da6d91 into main Aug 5, 2025
14 checks passed
@arsenm arsenm deleted the users/arsenm/runtime-libcalls/fix-stacksmash-arm64ec branch August 5, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants