@@ -474,6 +474,7 @@ def STACK_SMASH_HANDLER : RuntimeLibcall;
474474// Safe stack
475475def SAFESTACK_POINTER_ADDRESS : RuntimeLibcall;
476476
477+ def STACK_PROBE : RuntimeLibcall;
477478def SECURITY_CHECK_COOKIE : RuntimeLibcall;
478479
479480// Deoptimization
@@ -1188,6 +1189,15 @@ def __stack_smash_handler : RuntimeLibcallImpl<STACK_SMASH_HANDLER>;
11881189
11891190def __riscv_flush_icache : RuntimeLibcallImpl<RISCV_FLUSH_ICACHE>;
11901191
1192+ def _chkstk : RuntimeLibcallImpl<STACK_PROBE>;
1193+ def _alloca : RuntimeLibcallImpl<STACK_PROBE>;
1194+
1195+ def __chkstk : RuntimeLibcallImpl<STACK_PROBE>;
1196+ def ___chkstk_ms : RuntimeLibcallImpl<STACK_PROBE>;
1197+
1198+ def __chkstk_ms : RuntimeLibcallImpl<STACK_PROBE>;
1199+ def __chkstk_arm64ec : RuntimeLibcallImpl<STACK_PROBE, "#__chkstk_arm64ec">;
1200+
11911201def __security_check_cookie : RuntimeLibcallImpl<SECURITY_CHECK_COOKIE>;
11921202def __security_check_cookie_arm64ec : RuntimeLibcallImpl<SECURITY_CHECK_COOKIE,
11931203 "#__security_check_cookie_arm64ec">;
@@ -1330,6 +1340,9 @@ defvar SecurityCheckCookieIfWinMSVC =
13301340 LibcallImpls<(add __security_check_cookie, __security_cookie),
13311341 isWindowsMSVCOrItaniumEnvironment>;
13321342
1343+ defvar __chkstk_IfWinMSVC =
1344+ LibcallImpls<(add __chkstk), isWindowsMSVCEnvironment>;
1345+
13331346defvar LibmHasSinCosF32 = LibcallImpls<(add sincosf), hasSinCos>;
13341347defvar LibmHasSinCosF64 = LibcallImpls<(add sincos), hasSinCos>;
13351348defvar LibmHasSinCosF80 = LibcallImpls<(add sincosl_f80), hasSinCos>;
@@ -1488,6 +1501,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
14881501 DefaultLibmExp10,
14891502 DefaultStackProtector,
14901503 SecurityCheckCookieIfWinMSVC,
1504+ __chkstk_IfWinMSVC,
14911505 SMEABI_LibCalls_PreserveMost_From_X0,
14921506 SMEABI_LibCalls_PreserveMost_From_X1,
14931507 SMEABI_LibCalls_PreserveMost_From_X2)
@@ -1535,6 +1549,7 @@ def WindowsARM64ECSystemLibrary
15351549 LibcallImpls<(add __security_check_cookie_arm64ec,
15361550 __security_cookie),
15371551 isWindowsMSVCEnvironment>,
1552+ __chkstk_arm64ec,
15381553 ExceptionModelCallsArm64EC)>;
15391554
15401555//===----------------------------------------------------------------------===//
@@ -1952,6 +1967,7 @@ def ARMSystemLibrary
19521967 WindowARMDivRemCalls,
19531968 WindowARMFPIntCasts,
19541969 SecurityCheckCookieIfWinMSVC,
1970+ LibcallImpls<(add __chkstk), isOSWindows>,
19551971 AEABIDivRemCalls,
19561972 DarwinSinCosStret, DarwinExp10,
19571973 LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
@@ -2622,6 +2638,19 @@ def isX86_32 : RuntimeLibcallPredicate<"TT.getArch() == Triple::x86">;
26222638def isX86_64 : RuntimeLibcallPredicate<"TT.getArch() == Triple::x86_64">;
26232639def isX86 : RuntimeLibcallPredicate<"TT.isX86()">;
26242640
2641+ def isCygwinMinGW64 : RuntimeLibcallPredicate<
2642+ [{TT.isOSCygMing() && TT.getArch() == Triple::x86_64}]>;
2643+ def isCygwinMinGW32 : RuntimeLibcallPredicate<
2644+ [{TT.isOSCygMing() && TT.getArch() == Triple::x86}]>;
2645+
2646+ def isWin32NotCygMing : RuntimeLibcallPredicate<
2647+ [{TT.getArch() == Triple::x86 &&
2648+ (TT.isOSWindows() || TT.isUEFI()) && !TT.isOSCygMing()}]>;
2649+ def isWin64NotCygMing : RuntimeLibcallPredicate<
2650+ [{TT.getArch() == Triple::x86_64 &&
2651+ (TT.isOSWindows() || TT.isUEFI()) && !TT.isOSCygMing()}]>;
2652+
2653+
26252654// Some darwins have an optimized __bzero/bzero function.
26262655def darwinHas__bzero : RuntimeLibcallPredicate<"TT.isMacOSX() && !TT.isMacOSXVersionLT(10, 6)">;
26272656
@@ -2654,8 +2683,12 @@ defvar X86CommonLibcalls =
26542683 // hack for one test relying on it.
26552684 __powitf2_f128,
26562685 DefaultStackProtector,
2657- LibcallImpls<(add MemChkLibcalls), isNotPS>
2658- );
2686+ LibcallImpls<(add MemChkLibcalls), isNotPS>,
2687+ LibcallImpls<(add ___chkstk_ms), isCygwinMinGW64>,
2688+ LibcallImpls<(add __chkstk), isWin64NotCygMing>,
2689+ LibcallImpls<(add _alloca), isCygwinMinGW32>,
2690+ LibcallImpls<(add _chkstk), isWin32NotCygMing>
2691+ );
26592692
26602693defvar Windows32DivRemMulCalls =
26612694 LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
0 commit comments