diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def @@ -1048,6 +1048,12 @@ /// void memset_pattern16(void *b, const void *pattern16, size_t len); TLI_DEFINE_ENUM_INTERNAL(memset_pattern16) TLI_DEFINE_STRING_INTERNAL("memset_pattern16") +/// void memset_pattern4(void *b, const void *pattern4, size_t len); +TLI_DEFINE_ENUM_INTERNAL(memset_pattern4) +TLI_DEFINE_STRING_INTERNAL("memset_pattern4") +/// void memset_pattern8(void *b, const void *pattern8, size_t len); +TLI_DEFINE_ENUM_INTERNAL(memset_pattern8) +TLI_DEFINE_STRING_INTERNAL("memset_pattern8") /// int mkdir(const char *path, mode_t mode); TLI_DEFINE_ENUM_INTERNAL(mkdir) TLI_DEFINE_STRING_INTERNAL("mkdir") diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -166,8 +166,8 @@ return; } - // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later. - // All versions of watchOS support it. + // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and + // later. All versions of watchOS support it. if (T.isMacOSX()) { // available IO unlocked variants on Mac OS X TLI.setAvailable(LibFunc_getc_unlocked); @@ -175,12 +175,20 @@ TLI.setAvailable(LibFunc_putc_unlocked); TLI.setAvailable(LibFunc_putchar_unlocked); - if (T.isMacOSXVersionLT(10, 5)) + if (T.isMacOSXVersionLT(10, 5)) { + TLI.setUnavailable(LibFunc_memset_pattern4); + TLI.setUnavailable(LibFunc_memset_pattern8); TLI.setUnavailable(LibFunc_memset_pattern16); + } } else if (T.isiOS()) { - if (T.isOSVersionLT(3, 0)) + if (T.isOSVersionLT(3, 0)) { + TLI.setUnavailable(LibFunc_memset_pattern4); + TLI.setUnavailable(LibFunc_memset_pattern8); TLI.setUnavailable(LibFunc_memset_pattern16); + } } else if (!T.isWatchOS()) { + TLI.setUnavailable(LibFunc_memset_pattern4); + TLI.setUnavailable(LibFunc_memset_pattern8); TLI.setUnavailable(LibFunc_memset_pattern16); } @@ -1522,6 +1530,8 @@ FTy.getParamType(2)->isPointerTy() && FTy.getParamType(3)->isIntegerTy()); + case LibFunc_memset_pattern4: + case LibFunc_memset_pattern8: case LibFunc_memset_pattern16: return (!FTy.isVarArg() && NumParams == 3 && FTy.getParamType(0)->isPointerTy() && diff --git a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml --- a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml +++ b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml @@ -37,7 +37,7 @@ # ## The -COUNT suffix doesn't care if there are too many matches, so check ## the exact count first; the two directives should add up to that. -# AVAIL: TLI knows 466 symbols, 235 available +# AVAIL: TLI knows 468 symbols, 235 available # AVAIL-COUNT-235: {{^}} available # UNAVAIL-COUNT-231: not available diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp --- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp +++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -240,6 +240,8 @@ "declare i8* @memmove(i8*, i8*, i64)\n" "declare i8* @memset(i8*, i32, i64)\n" "declare void @memset_pattern16(i8*, i8*, i64)\n" + "declare void @memset_pattern4(i8*, i8*, i64)\n" + "declare void @memset_pattern8(i8*, i8*, i64)\n" "declare i32 @mkdir(i8*, i16)\n" "declare double @modf(double, double*)\n" "declare float @modff(float, float*)\n" @@ -521,7 +523,8 @@ "declare i32 @iprintf(i8*, ...)\n" "declare i32 @siprintf(i8*, i8*, ...)\n" - // __small_printf variants have the same prototype as the non-'i' versions. + // __small_printf variants have the same prototype as the non-'i' + // versions. "declare i32 @__small_fprintf(%struct*, i8*, ...)\n" "declare i32 @__small_printf(i8*, ...)\n" "declare i32 @__small_sprintf(i8*, i8*, ...)\n" @@ -589,8 +592,7 @@ // These functions are OpenMP Offloading allocation / free routines "declare i8* @__kmpc_alloc_shared(i64)\n" - "declare void @__kmpc_free_shared(i8*, i64)\n" - ); + "declare void @__kmpc_free_shared(i8*, i64)\n"); for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) { LibFunc LF = (LibFunc)FI;