diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def index 5914324b286c05..ebc917ea53eb8d 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def @@ -2183,6 +2183,21 @@ TLI_DEFINE_ENUM_INTERNAL(sinl) TLI_DEFINE_STRING_INTERNAL("sinl") TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl) +/// void sincos(double x, double *sin_out, double *cos_out); +TLI_DEFINE_ENUM_INTERNAL(sincos) +TLI_DEFINE_STRING_INTERNAL("sincos") +TLI_DEFINE_SIG_INTERNAL(Void, Dbl, Ptr, Ptr) + +/// void sincosf(float x, float *sin_out, float *cos_out); +TLI_DEFINE_ENUM_INTERNAL(sincosf) +TLI_DEFINE_STRING_INTERNAL("sincosf") +TLI_DEFINE_SIG_INTERNAL(Void, Flt, Ptr, Ptr) + +/// void sincosl(long double x, long double *sin_out, long double *cos_out); +TLI_DEFINE_ENUM_INTERNAL(sincosl) +TLI_DEFINE_STRING_INTERNAL("sincosl") +TLI_DEFINE_SIG_INTERNAL(Void, LDbl, Ptr, Ptr) + /// int siprintf(char *str, const char *format, ...); TLI_DEFINE_ENUM_INTERNAL(siprintf) TLI_DEFINE_STRING_INTERNAL("siprintf") diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp index b0da19813f0a4b..f6448883287587 100644 --- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp @@ -1270,6 +1270,18 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F, Changed |= setOnlyWritesMemory(F); Changed |= setWillReturn(F); break; + case LibFunc_sincos: + case LibFunc_sincosf: + case LibFunc_sincosl: + Changed |= setDoesNotThrow(F); + Changed |= setDoesNotFreeMemory(F); + Changed |= setOnlyWritesMemory(F); + Changed |= setOnlyWritesMemory(F, 1); + Changed |= setOnlyWritesMemory(F, 2); + Changed |= setDoesNotCapture(F, 1); + Changed |= setDoesNotCapture(F, 2); + Changed |= setWillReturn(F); + break; default: // FIXME: It'd be really nice to cover all the library functions we're // aware of here. diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll index bc0d7a509e1f5d..40c512c81f0c9d 100644 --- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll +++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll @@ -1106,6 +1106,15 @@ declare void @__cxa_throw(ptr, ptr, ptr) ; CHECK: declare void @_ZSt9terminatev() [[NOFREE_COLD_NORETURN:#[0-9]+]] declare void @_ZSt9terminatev() +; CHECK: declare void @sincos(double, ptr nocapture writeonly, ptr nocapture writeonly) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]] +declare void @sincos(double, ptr, ptr) + +; CHECK: declare void @sincosf(float, ptr nocapture writeonly, ptr nocapture writeonly) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]] +declare void @sincosf(float, ptr, ptr) + +; CHECK: declare void @sincosl(x86_fp80, ptr nocapture writeonly, ptr nocapture writeonly) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]] +declare void @sincosl(x86_fp80, ptr, ptr) + ; memset_pattern{4,8,16} aren't available everywhere. ; CHECK-DARWIN: declare void @memset_pattern4(ptr nocapture writeonly, ptr nocapture readonly, i64) [[ARGMEMONLY_NOFREE_NOUNWIND_WILLRETURN]] declare void @memset_pattern4(ptr, ptr, i64) diff --git a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml index 47aeb0ad8fdef9..26efb2bc97cd14 100644 --- a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml +++ b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml @@ -34,7 +34,7 @@ # # CHECK: << Total TLI yes SDK no: 18 # CHECK: >> Total TLI no SDK yes: 0 -# CHECK: == Total TLI yes SDK yes: 250 +# CHECK: == Total TLI yes SDK yes: 253 # # WRONG_DETAIL: << TLI yes SDK no : '_ZdaPv' aka operator delete[](void*) # WRONG_DETAIL: >> TLI no SDK yes: '_ZdaPvj' aka operator delete[](void*, unsigned int) @@ -48,14 +48,14 @@ # WRONG_DETAIL: << TLI yes SDK no : 'fminimum_numl' # WRONG_SUMMARY: << Total TLI yes SDK no: 19{{$}} # WRONG_SUMMARY: >> Total TLI no SDK yes: 1{{$}} -# WRONG_SUMMARY: == Total TLI yes SDK yes: 249 +# WRONG_SUMMARY: == Total TLI yes SDK yes: 252 # ## 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. ## Yes, this means additions to TLI will fail this test, but the argument ## to -COUNT can't be an expression. -# AVAIL: TLI knows 501 symbols, 268 available -# AVAIL-COUNT-268: {{^}} available +# AVAIL: TLI knows 504 symbols, 271 available +# AVAIL-COUNT-271: {{^}} available # AVAIL-NOT: {{^}} available # UNAVAIL-COUNT-233: not available # UNAVAIL-NOT: not available @@ -862,6 +862,18 @@ DynamicSymbols: Type: STT_FUNC Section: .text Binding: STB_GLOBAL + - Name: sincos + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + - Name: sincosf + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + - Name: sincosl + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL - Name: sinh Type: STT_FUNC Section: .text diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp index c081c44ed35d00..ac8ccc03399e14 100644 --- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp +++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -339,6 +339,9 @@ TEST_F(TargetLibraryInfoTest, ValidProto) { "declare float @sinhf(float)\n" "declare x86_fp80 @sinhl(x86_fp80)\n" "declare x86_fp80 @sinl(x86_fp80)\n" + "declare void @sincos(double, ptr, ptr)\n" + "declare void @sincosf(float, ptr, ptr)\n" + "declare void @sincosl(x86_fp80, ptr, ptr)\n" "declare i32 @snprintf(i8*, i64, i8*, ...)\n" "declare i32 @sprintf(i8*, i8*, ...)\n" "declare double @sqrt(double)\n"