@@ -406,6 +406,7 @@ def STACK_SMASH_HANDLER : RuntimeLibcall;
406406// Safe stack
407407def SAFESTACK_POINTER_ADDRESS : RuntimeLibcall;
408408
409+ def STACK_PROBE : RuntimeLibcall;
409410def SECURITY_CHECK_COOKIE : RuntimeLibcall;
410411
411412// Deoptimization
@@ -1084,6 +1085,15 @@ def __stack_smash_handler : RuntimeLibcallImpl<STACK_SMASH_HANDLER>;
10841085
10851086def __riscv_flush_icache : RuntimeLibcallImpl<RISCV_FLUSH_ICACHE>;
10861087
1088+ def _chkstk : RuntimeLibcallImpl<STACK_PROBE>;
1089+ def _alloca : RuntimeLibcallImpl<STACK_PROBE>;
1090+
1091+ def __chkstk : RuntimeLibcallImpl<STACK_PROBE>;
1092+ def ___chkstk_ms : RuntimeLibcallImpl<STACK_PROBE>;
1093+
1094+ def __chkstk_ms : RuntimeLibcallImpl<STACK_PROBE>;
1095+ def __chkstk_arm64ec : RuntimeLibcallImpl<STACK_PROBE, "#__chkstk_arm64ec">;
1096+
10871097def __security_check_cookie : RuntimeLibcallImpl<SECURITY_CHECK_COOKIE>;
10881098def __security_check_cookie_arm64ec : RuntimeLibcallImpl<SECURITY_CHECK_COOKIE,
10891099 "#__security_check_cookie_arm64ec">;
@@ -1260,6 +1270,9 @@ defvar SecurityCheckCookieIfWinMSVC =
12601270 LibcallImpls<(add __security_check_cookie, __security_cookie),
12611271 isWindowsMSVCOrItaniumEnvironment>;
12621272
1273+ defvar __chkstk_IfWinMSVC =
1274+ LibcallImpls<(add __chkstk), isWindowsMSVCEnvironment>;
1275+
12631276defvar LibmHasSinCosF32 = LibcallImpls<(add sincosf), hasSinCos>;
12641277defvar LibmHasSinCosF64 = LibcallImpls<(add sincos), hasSinCos>;
12651278defvar LibmHasSinCosF80 = LibcallImpls<(add sincosl_f80), hasSinCos>;
@@ -1418,6 +1431,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
14181431 DefaultLibmExp10,
14191432 DefaultStackProtector,
14201433 SecurityCheckCookieIfWinMSVC,
1434+ __chkstk_IfWinMSVC,
14211435 SMEABI_LibCalls_PreserveMost_From_X0,
14221436 SMEABI_LibCalls_PreserveMost_From_X1,
14231437 SMEABI_LibCalls_PreserveMost_From_X2)
@@ -1465,6 +1479,7 @@ def WindowsARM64ECSystemLibrary
14651479 LibcallImpls<(add __security_check_cookie_arm64ec,
14661480 __security_cookie),
14671481 isWindowsMSVCEnvironment>,
1482+ __chkstk_arm64ec,
14681483 ExceptionModelCallsArm64EC)>;
14691484
14701485//===----------------------------------------------------------------------===//
@@ -1882,6 +1897,7 @@ def ARMSystemLibrary
18821897 WindowARMDivRemCalls,
18831898 WindowARMFPIntCasts,
18841899 SecurityCheckCookieIfWinMSVC,
1900+ LibcallImpls<(add __chkstk), isOSWindows>,
18851901 AEABIDivRemCalls,
18861902 DarwinSinCosStret, DarwinExp10,
18871903 LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
@@ -2552,6 +2568,19 @@ def isX86_32 : RuntimeLibcallPredicate<"TT.getArch() == Triple::x86">;
25522568def isX86_64 : RuntimeLibcallPredicate<"TT.getArch() == Triple::x86_64">;
25532569def isX86 : RuntimeLibcallPredicate<"TT.isX86()">;
25542570
2571+ def isCygwinMinGW64 : RuntimeLibcallPredicate<
2572+ [{TT.isOSCygMing() && TT.getArch() == Triple::x86_64}]>;
2573+ def isCygwinMinGW32 : RuntimeLibcallPredicate<
2574+ [{TT.isOSCygMing() && TT.getArch() == Triple::x86}]>;
2575+
2576+ def isWin32NotCygMing : RuntimeLibcallPredicate<
2577+ [{TT.getArch() == Triple::x86 &&
2578+ (TT.isOSWindows() || TT.isUEFI()) && !TT.isOSCygMing()}]>;
2579+ def isWin64NotCygMing : RuntimeLibcallPredicate<
2580+ [{TT.getArch() == Triple::x86_64 &&
2581+ (TT.isOSWindows() || TT.isUEFI()) && !TT.isOSCygMing()}]>;
2582+
2583+
25552584// Some darwins have an optimized __bzero/bzero function.
25562585def darwinHas__bzero : RuntimeLibcallPredicate<"TT.isMacOSX() && !TT.isMacOSXVersionLT(10, 6)">;
25572586
@@ -2581,8 +2610,12 @@ defvar X86CommonLibcalls =
25812610 // FIXME: MSVCRT doesn't have powi. The f128 case is added as a
25822611 // hack for one test relying on it.
25832612 __powitf2_f128,
2584- DefaultStackProtector
2585- );
2613+ DefaultStackProtector,
2614+ LibcallImpls<(add ___chkstk_ms), isCygwinMinGW64>,
2615+ LibcallImpls<(add __chkstk), isWin64NotCygMing>,
2616+ LibcallImpls<(add _alloca), isCygwinMinGW32>,
2617+ LibcallImpls<(add _chkstk), isWin32NotCygMing>
2618+ );
25862619
25872620defvar Windows32DivRemMulCalls =
25882621 LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
0 commit comments