@@ -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<
@@ -375,8 +378,11 @@ foreach FPTy = ["F32", "F64", "F128", "PPCF128"] in {
375378// Memory
376379def MEMCMP : RuntimeLibcall;
377380def MEMCPY : RuntimeLibcall;
381+ def MEMCPY_CHK : RuntimeLibcall;
378382def MEMMOVE : RuntimeLibcall;
383+ def MEMMOVE_CHK : RuntimeLibcall;
379384def MEMSET : RuntimeLibcall;
385+ def MEMSET_CHK : RuntimeLibcall;
380386def CALLOC : RuntimeLibcall;
381387def BZERO : RuntimeLibcall;
382388def STRLEN : RuntimeLibcall;
@@ -1092,6 +1098,10 @@ def memcpy : RuntimeLibcallImpl<MEMCPY>;
10921098def memmove : RuntimeLibcallImpl<MEMMOVE>;
10931099def memset : RuntimeLibcallImpl<MEMSET>;
10941100
1101+ def __memcpy_chk : RuntimeLibcallImpl<MEMCPY_CHK>;
1102+ def __memmove_chk : RuntimeLibcallImpl<MEMMOVE_CHK>;
1103+ def __memset_chk : RuntimeLibcallImpl<MEMSET_CHK>;
1104+
10951105// DSEPass can emit calloc if it finds a pair of malloc/memset
10961106def calloc : RuntimeLibcallImpl<CALLOC>;
10971107
@@ -2625,8 +2635,10 @@ defvar X86_F128_Libcalls = LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLib
26252635
26262636defvar SinCosF32F64Libcalls = LibcallImpls<(add sincosf, sincos), hasSinCos_f32_f64>;
26272637
2638+ defvar MemChkLibcalls = [__memcpy_chk, __memset_chk, __memmove_chk];
2639+
26282640defvar X86CommonLibcalls =
2629- (add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides),
2641+ (add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides, MemChkLibcalls ),
26302642 DarwinSinCosStret, DarwinExp10,
26312643 X86_F128_Libcalls,
26322644 LibmHasSinCosF80, // FIXME: Depends on long double
@@ -2642,7 +2654,8 @@ defvar X86CommonLibcalls =
26422654 // FIXME: MSVCRT doesn't have powi. The f128 case is added as a
26432655 // hack for one test relying on it.
26442656 __powitf2_f128,
2645- DefaultStackProtector
2657+ DefaultStackProtector,
2658+ LibcallImpls<(add MemChkLibcalls), isNotPS>
26462659 );
26472660
26482661defvar Windows32DivRemMulCalls =
0 commit comments