[llvm] SystemZ: Remove override of insertSSPDeclarations (PR #163708)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 20 08:28:43 PST 2026
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/163708
>From b1b7b7ee963533e0ae56170bfc8f8c714ff13e31 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 16 Oct 2025 15:41:42 +0900
Subject: [PATCH] SystemZ: Remove override of insertSSPDeclarations
Remove __stack_chk_guard from the SystemZ system library.
Previously the availability was assumed to match
__stack_chk_fail, but these appear to be differen for SystemZ.
I'm assuming this isn't available for systemz based on the
existing behavior.
Once the runtime library does not add a SYSTEM_CHECK_GUARD
implementation the default will be a no-op if the symbol
isn't added to the system.
Also extend the test to make sure the declaration is not emitted.
---
llvm/include/llvm/IR/RuntimeLibcalls.td | 6 +++++-
llvm/lib/Target/SystemZ/SystemZISelLowering.h | 3 ---
llvm/test/CodeGen/SystemZ/stack-guard.ll | 13 ++++++++++++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index c22a3bc994457..57d1e88c97eeb 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -45,6 +45,10 @@ def hasStackChkFail : RuntimeLibcallPredicate<
[{ !TT.isOSOpenBSD() && !TT.isWindowsMSVCEnvironment() &&
!TT.isWindowsItaniumEnvironment()}]>;
+def hasStackChkGuard : RuntimeLibcallPredicate<
+ [{ !TT.isOSOpenBSD() && !TT.isWindowsMSVCEnvironment() &&
+ !TT.isWindowsItaniumEnvironment() && !TT.isSystemZ()}]>;
+
def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallPredicate<
[{TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()}]>;
@@ -2044,7 +2048,7 @@ defvar LibmHasLdexpF128 = LibcallImpls<(add ldexpl_f128), isNotOSWindowsOrIsCygw
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), hasStackChkFail>;
defvar has__stack_chk_guard =
- LibcallImpls<(add __stack_chk_guard), hasStackChkFail>;
+ LibcallImpls<(add __stack_chk_guard), hasStackChkGuard>;
defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
defvar has___guard_local = LibcallImpls<(add __guard_local), isOSOpenBSD>;
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
index 9e1b4e66f1fe8..36fd1d6193154 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -220,9 +220,6 @@ class SystemZTargetLowering : public TargetLowering {
/// Override to support customized stack guard loading.
bool useLoadStackGuardNode(const Module &M) const override { return true; }
- void
- insertSSPDeclarations(Module &M,
- const LibcallLoweringInfo &Libcalls) const override {}
MachineBasicBlock *
EmitInstrWithCustomInserter(MachineInstr &MI,
diff --git a/llvm/test/CodeGen/SystemZ/stack-guard.ll b/llvm/test/CodeGen/SystemZ/stack-guard.ll
index 04a87b4632dd2..fd661a40b38ec 100644
--- a/llvm/test/CodeGen/SystemZ/stack-guard.ll
+++ b/llvm/test/CodeGen/SystemZ/stack-guard.ll
@@ -1,4 +1,15 @@
-; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; RUN: opt -S -mtriple=s390x-linux-gnu -passes='require<libcall-lowering-info>,stack-protector' < %s | FileCheck -check-prefix=IR %s
+; RUN: opt -S -mtriple=s390x-ibm-zos -passes='require<libcall-lowering-info>,stack-protector' < %s | FileCheck -check-prefix=IR %s
+; RUN: llc -mtriple=s390x-linux-gnu < %s | FileCheck %s
+
+; FIXME: Codegen error with zos
+
+; IR-NOT: __stack_chk_guard
+; IR-NOT: @
+
+; IR: define i32 @test_stack_guard
+
+; IR-NOT: __stack_chk_guard
; CHECK-LABEL: @test_stack_guard
; CHECK: ear [[REG1:%r[1-9][0-9]?]], %a0
More information about the llvm-commits
mailing list