@@ -35,6 +35,9 @@ def isNotOSLinuxAndNotOSOpenBSD : RuntimeLibcallPredicate<
3535def isNotOSAIXAndNotOSOpenBSD : RuntimeLibcallPredicate<
3636 [{!TT.isOSAIX() && !TT.isOSOpenBSD()}]>;
3737
38+ def isNotPS : RuntimeLibcallPredicate<
39+ [{!TT.isPS()}]>;
40+
3841// OpenBSD uses __guard_local. AIX uses __ssp_canary_word, MSVC/Windows
3942// Itanium uses __security_cookie
4043def hasStackChkFail : RuntimeLibcallPredicate<
@@ -374,8 +377,11 @@ foreach FPTy = ["F32", "F64", "F128", "PPCF128"] in {
374377// Memory
375378def MEMCMP : RuntimeLibcall;
376379def MEMCPY : RuntimeLibcall;
380+ def MEMCPY_CHK : RuntimeLibcall;
377381def MEMMOVE : RuntimeLibcall;
382+ def MEMMOVE_CHK : RuntimeLibcall;
378383def MEMSET : RuntimeLibcall;
384+ def MEMSET_CHK : RuntimeLibcall;
379385def CALLOC : RuntimeLibcall;
380386def BZERO : RuntimeLibcall;
381387def STRLEN : RuntimeLibcall;
@@ -1091,6 +1097,10 @@ def memcpy : RuntimeLibcallImpl<MEMCPY>;
10911097def memmove : RuntimeLibcallImpl<MEMMOVE>;
10921098def memset : RuntimeLibcallImpl<MEMSET>;
10931099
1100+ def __memcpy_chk : RuntimeLibcallImpl<MEMCPY_CHK>;
1101+ def __memmove_chk : RuntimeLibcallImpl<MEMMOVE_CHK>;
1102+ def __memset_chk : RuntimeLibcallImpl<MEMSET_CHK>;
1103+
10941104// DSEPass can emit calloc if it finds a pair of malloc/memset
10951105def calloc : RuntimeLibcallImpl<CALLOC>;
10961106
@@ -2624,8 +2634,10 @@ defvar X86_F128_Libcalls = LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLib
26242634
26252635defvar SinCosF32F64Libcalls = LibcallImpls<(add sincosf, sincos), hasSinCos_f32_f64>;
26262636
2637+ defvar MemChkLibcalls = [__memcpy_chk, __memset_chk, __memmove_chk];
2638+
26272639defvar X86CommonLibcalls =
2628- (add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides),
2640+ (add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides, MemChkLibcalls ),
26292641 DarwinSinCosStret, DarwinExp10,
26302642 X86_F128_Libcalls,
26312643 LibmHasSinCosF80, // FIXME: Depends on long double
@@ -2641,7 +2653,8 @@ defvar X86CommonLibcalls =
26412653 // FIXME: MSVCRT doesn't have powi. The f128 case is added as a
26422654 // hack for one test relying on it.
26432655 __powitf2_f128,
2644- DefaultStackProtector
2656+ DefaultStackProtector,
2657+ LibcallImpls<(add MemChkLibcalls), isNotPS>
26452658 );
26462659
26472660defvar Windows32DivRemMulCalls =
0 commit comments