https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/150870
>From aafeda09375b5093b1454dde9171564f33bdb7c7 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Mon, 28 Jul 2025 11:47:04 +0900 Subject: [PATCH 1/2] RuntimeLibcalls: Move __stack_smash_handler config to tablegen --- llvm/include/llvm/IR/RuntimeLibcalls.td | 17 ++++++++++------- llvm/lib/IR/RuntimeLibcalls.cpp | 3 --- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td index e31573b04cb4b..8ae1882ab9475 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.td +++ b/llvm/include/llvm/IR/RuntimeLibcalls.td @@ -1151,6 +1151,7 @@ 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>; //===----------------------------------------------------------------------===// // Objective-C Runtime Libcalls @@ -1229,7 +1230,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary< DarwinExp10, DarwinSinCosStret, LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128, DefaultLibmExp10, - has__stack_chk_fail) + has__stack_chk_fail, has__stack_smash_handler) >; // Prepend a # to every name @@ -1506,7 +1507,7 @@ def ARMSystemLibrary LibcallImpls<(add __divmodsi4, __udivmodsi4), RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() && (!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>, - has__stack_chk_fail)> { + has__stack_chk_fail, has__stack_smash_handler)> { let DefaultLibcallCallingConv = LibcallCallingConv<[{ (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) ? (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP @@ -2015,7 +2016,7 @@ def PPCSystemLibrary LibmHasSinCosPPCF128, AvailableIf<memcpy, isNotAIX>, LibcallImpls<(add Int128RTLibcalls), isPPC64>, - has__stack_chk_fail)>; + has__stack_chk_fail, has__stack_smash_handler)>; //===----------------------------------------------------------------------===// // RISCV Runtime Libcalls @@ -2030,7 +2031,7 @@ def RISCVSystemLibrary exp10f, exp10, exp10l_f128, __riscv_flush_icache, LibcallImpls<(add Int128RTLibcalls), isRISCV64>, - has__stack_chk_fail)>; + has__stack_chk_fail, has__stack_smash_handler)>; //===----------------------------------------------------------------------===// // SPARC Runtime Libcalls @@ -2098,7 +2099,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) + has__stack_chk_fail, has__stack_smash_handler) >; //===----------------------------------------------------------------------===// @@ -2159,7 +2160,8 @@ 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 + has__stack_chk_fail, + has__stack_smash_handler ); defvar Windows32DivRemMulCalls = @@ -2328,5 +2330,6 @@ def LegacyDefaultSystemLibrary exp10f, exp10, exp10l_f128, __powisf2, __powidf2, __powitf2_f128, LibcallImpls<(add Int128RTLibcalls), isArch64Bit>, - has__stack_chk_fail + has__stack_chk_fail, + has__stack_smash_handler )>; diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index bfe2a3d6af867..a930414d177c5 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -78,9 +78,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT, 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; >From e3cf6b53f958256f08e67752a961aa84214cd71a Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Sun, 3 Aug 2025 07:33:05 +0900 Subject: [PATCH 2/2] DefaultStackProtector --- llvm/include/llvm/IR/RuntimeLibcalls.td | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td index 8ae1882ab9475..384b7f29b9073 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.td +++ b/llvm/include/llvm/IR/RuntimeLibcalls.td @@ -1153,6 +1153,9 @@ defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwi 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 //===----------------------------------------------------------------------===// @@ -1230,7 +1233,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary< DarwinExp10, DarwinSinCosStret, LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128, DefaultLibmExp10, - has__stack_chk_fail, has__stack_smash_handler) + DefaultStackProtector) >; // Prepend a # to every name @@ -1507,7 +1510,7 @@ def ARMSystemLibrary LibcallImpls<(add __divmodsi4, __udivmodsi4), RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() && (!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>, - has__stack_chk_fail, has__stack_smash_handler)> { + DefaultStackProtector)> { let DefaultLibcallCallingConv = LibcallCallingConv<[{ (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) ? (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP @@ -2016,7 +2019,7 @@ def PPCSystemLibrary LibmHasSinCosPPCF128, AvailableIf<memcpy, isNotAIX>, LibcallImpls<(add Int128RTLibcalls), isPPC64>, - has__stack_chk_fail, has__stack_smash_handler)>; + DefaultStackProtector)>; //===----------------------------------------------------------------------===// // RISCV Runtime Libcalls @@ -2031,7 +2034,7 @@ def RISCVSystemLibrary exp10f, exp10, exp10l_f128, __riscv_flush_icache, LibcallImpls<(add Int128RTLibcalls), isRISCV64>, - has__stack_chk_fail, has__stack_smash_handler)>; + DefaultStackProtector)>; //===----------------------------------------------------------------------===// // SPARC Runtime Libcalls @@ -2099,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, has__stack_smash_handler) + DefaultStackProtector) >; //===----------------------------------------------------------------------===// @@ -2160,8 +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, - has__stack_smash_handler + DefaultStackProtector ); defvar Windows32DivRemMulCalls = @@ -2330,6 +2332,5 @@ def LegacyDefaultSystemLibrary exp10f, exp10, exp10l_f128, __powisf2, __powidf2, __powitf2_f128, LibcallImpls<(add Int128RTLibcalls), isArch64Bit>, - has__stack_chk_fail, - has__stack_smash_handler + DefaultStackProtector )>; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits