Skip to content

Commit d9e08a6

Browse files
committed
RuntimeLibcalls: Move __stack_chk_fail config to tablegen
1 parent 39867e3 commit d9e08a6

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class DuplicateLibcallImplWithPrefix<RuntimeLibcallImpl Impl, string prefix>
1818
/// Libcall Predicates
1919
def isOSDarwin : RuntimeLibcallPredicate<"TT.isOSDarwin()">;
2020
def isOSOpenBSD : RuntimeLibcallPredicate<"TT.isOSOpenBSD()">;
21+
def isNotOSOpenBSD : RuntimeLibcallPredicate<"!TT.isOSOpenBSD()">;
2122
def isOSWindows : RuntimeLibcallPredicate<"TT.isOSWindows()">;
2223
def isNotOSWindows : RuntimeLibcallPredicate<"!TT.isOSWindows()">;
2324
def isNotOSMSVCRT : RuntimeLibcallPredicate<"!TT.isOSMSVCRT()">;
@@ -698,9 +699,6 @@ foreach lc = LibCalls__atomic in {
698699
def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>;
699700
}
700701

701-
// Stack Protector Fail
702-
def __stack_chk_fail : RuntimeLibcallImpl<STACKPROTECTOR_CHECK_FAIL>;
703-
704702
// Deoptimization
705703
def __llvm_deoptimize : RuntimeLibcallImpl<DEOPTIMIZE>;
706704

@@ -945,6 +943,9 @@ def exp10l_f80 : RuntimeLibcallImpl<EXP10_F80, "exp10l">;
945943
def exp10l_f128 : RuntimeLibcallImpl<EXP10_F128, "exp10l">;
946944
def exp10l_ppcf128 : RuntimeLibcallImpl<EXP10_PPCF128, "exp10l">;
947945

946+
// Stack Protector Fail
947+
def __stack_chk_fail : RuntimeLibcallImpl<STACKPROTECTOR_CHECK_FAIL>;
948+
948949
//--------------------------------------------------------------------
949950
// compiler-rt/libgcc but 64-bit only, not available by default
950951
//--------------------------------------------------------------------
@@ -1128,6 +1129,7 @@ defvar LibmHasLdexpF80 = LibcallImpls<(add ldexp_f80), isNotOSWindowsOrIsCygwinM
11281129
defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
11291130
defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
11301131

1132+
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
11311133

11321134
//===----------------------------------------------------------------------===//
11331135
// Objective-C Runtime Libcalls
@@ -1205,7 +1207,8 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
12051207
LibcallImpls<(add bzero), isOSDarwin>,
12061208
DarwinExp10, DarwinSinCosStret,
12071209
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1208-
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128)
1210+
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128,
1211+
has__stack_chk_fail)
12091212
>;
12101213

12111214
// Prepend a # to every name
@@ -1481,7 +1484,8 @@ def ARMSystemLibrary
14811484
// Use divmod compiler-rt calls for iOS 5.0 and later.
14821485
LibcallImpls<(add __divmodsi4, __udivmodsi4),
14831486
RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
1484-
(!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>)> {
1487+
(!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>,
1488+
has__stack_chk_fail)> {
14851489
let DefaultLibcallCallingConv = LibcallCallingConv<[{
14861490
(!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) ?
14871491
(FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -1976,7 +1980,8 @@ def PPCSystemLibrary
19761980
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
19771981
LibmHasSinCosPPCF128,
19781982
AvailableIf<memcpy, isNotAIX>,
1979-
LibcallImpls<(add Int128RTLibcalls), isPPC64>)>;
1983+
LibcallImpls<(add Int128RTLibcalls), isPPC64>,
1984+
has__stack_chk_fail)>;
19801985

19811986
//===----------------------------------------------------------------------===//
19821987
// RISCV Runtime Libcalls
@@ -1990,7 +1995,8 @@ def RISCVSystemLibrary
19901995
(add DefaultRuntimeLibcallImpls,
19911996
exp10f, exp10, exp10l_f128,
19921997
__riscv_flush_icache,
1993-
LibcallImpls<(add Int128RTLibcalls), isRISCV64>)>;
1998+
LibcallImpls<(add Int128RTLibcalls), isRISCV64>,
1999+
has__stack_chk_fail)>;
19942000

19952001
//===----------------------------------------------------------------------===//
19962002
// SPARC Runtime Libcalls
@@ -2057,7 +2063,8 @@ def SPARCSystemLibrary
20572063
sparc_umul, sparc_div, sparc_udiv, sparc_rem, sparc_urem,
20582064
LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
20592065
LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
2060-
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128)
2066+
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
2067+
has__stack_chk_fail)
20612068
>;
20622069

20632070
//===----------------------------------------------------------------------===//
@@ -2106,7 +2113,8 @@ defvar X86CommonLibcalls =
21062113
LibcallImpls<(add MostPowI), isNotOSMSVCRT>,
21072114
// FIXME: MSVCRT doesn't have powi. The f128 case is added as a
21082115
// hack for one test relying on it.
2109-
__powitf2_f128
2116+
__powitf2_f128,
2117+
has__stack_chk_fail
21102118
);
21112119

21122120
defvar Windows32DivRemMulCalls =
@@ -2251,7 +2259,8 @@ def WasmSystemLibrary
22512259
(add DefaultRuntimeLibcallImpls, Int128RTLibcalls,
22522260
CompilerRTOnlyInt64Libcalls, CompilerRTOnlyInt128Libcalls,
22532261
exp10f, exp10,
2254-
emscripten_return_address)>;
2262+
emscripten_return_address,
2263+
__stack_chk_fail)>;
22552264

22562265
//===----------------------------------------------------------------------===//
22572266
// Legacy Default Runtime Libcalls
@@ -2274,5 +2283,6 @@ def LegacyDefaultSystemLibrary
22742283
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
22752284
exp10f, exp10, exp10l_f128,
22762285
__powisf2, __powidf2, __powitf2_f128,
2277-
LibcallImpls<(add Int128RTLibcalls), isArch64Bit>
2286+
LibcallImpls<(add Int128RTLibcalls), isArch64Bit>,
2287+
has__stack_chk_fail
22782288
)>;

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
7777
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
7878
}
7979

80-
if (TT.isOSOpenBSD()) {
81-
setLibcallImpl(RTLIB::STACKPROTECTOR_CHECK_FAIL, RTLIB::Unsupported);
82-
}
83-
8480
if (TT.isARM() || TT.isThumb()) {
8581
setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
8682
return;

0 commit comments

Comments
 (0)