[llvm] 1862e3c - RuntimeLibcalls: Move __stack_smash_handler config to tablegen (#150870)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 01:27:48 PDT 2025


Author: Matt Arsenault
Date: 2025-08-04T17:27:44+09:00
New Revision: 1862e3c56ce1eb3762b4ccd6e9e222f3022c9c7c

URL: https://github.com/llvm/llvm-project/commit/1862e3c56ce1eb3762b4ccd6e9e222f3022c9c7c
DIFF: https://github.com/llvm/llvm-project/commit/1862e3c56ce1eb3762b4ccd6e9e222f3022c9c7c.diff

LOG: RuntimeLibcalls: Move __stack_smash_handler config to tablegen (#150870)

Added: 
    

Modified: 
    llvm/include/llvm/IR/RuntimeLibcalls.td
    llvm/lib/IR/RuntimeLibcalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index e31573b04cb4b..384b7f29b9073 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1151,6 +1151,10 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), isNotOSWindowsOrIsCygwi
 defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
 
 defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
+defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
+
+defvar DefaultStackProtector = (add has__stack_chk_fail,
+                                    has__stack_smash_handler);
 
 //===----------------------------------------------------------------------===//
 // Objective-C Runtime Libcalls
@@ -1229,7 +1233,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
        DarwinExp10, DarwinSinCosStret,
        LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
        DefaultLibmExp10,
-       has__stack_chk_fail)
+       DefaultStackProtector)
 >;
 
 // Prepend a # to every name
@@ -1506,7 +1510,7 @@ def ARMSystemLibrary
            LibcallImpls<(add __divmodsi4, __udivmodsi4),
                         RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
                                                   (!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>,
-           has__stack_chk_fail)> {
+           DefaultStackProtector)> {
   let DefaultLibcallCallingConv = LibcallCallingConv<[{
      (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) ?
         (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -2015,7 +2019,7 @@ def PPCSystemLibrary
            LibmHasSinCosPPCF128,
            AvailableIf<memcpy, isNotAIX>,
            LibcallImpls<(add Int128RTLibcalls), isPPC64>,
-           has__stack_chk_fail)>;
+           DefaultStackProtector)>;
 
 //===----------------------------------------------------------------------===//
 // RISCV Runtime Libcalls
@@ -2030,7 +2034,7 @@ def RISCVSystemLibrary
            exp10f, exp10, exp10l_f128,
            __riscv_flush_icache,
            LibcallImpls<(add Int128RTLibcalls), isRISCV64>,
-           has__stack_chk_fail)>;
+           DefaultStackProtector)>;
 
 //===----------------------------------------------------------------------===//
 // SPARC Runtime Libcalls
@@ -2098,7 +2102,7 @@ def SPARCSystemLibrary
        LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
        LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
        LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
-       has__stack_chk_fail)
+       DefaultStackProtector)
 >;
 
 //===----------------------------------------------------------------------===//
@@ -2159,7 +2163,7 @@ defvar X86CommonLibcalls =
        // FIXME: MSVCRT doesn't have powi. The f128 case is added as a
        // hack for one test relying on it.
        __powitf2_f128,
-       has__stack_chk_fail
+       DefaultStackProtector
 );
 
 defvar Windows32DivRemMulCalls =
@@ -2328,5 +2332,5 @@ def LegacyDefaultSystemLibrary
          exp10f, exp10, exp10l_f128,
          __powisf2, __powidf2, __powitf2_f128,
          LibcallImpls<(add Int128RTLibcalls), isArch64Bit>,
-         has__stack_chk_fail
+         DefaultStackProtector
 )>;

diff  --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 1ba2fa7f93b03..b6e2cac5f7b04 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -76,9 +76,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
   if (ExceptionModel == ExceptionHandling::SjLj)
     setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
 
-  if (TT.isOSOpenBSD())
-    setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);
-
   if (TT.isARM() || TT.isThumb()) {
     setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
     return;


        


More information about the llvm-commits mailing list