Skip to content

Commit

Permalink
[TLI] Add support for the tgamma libcall. (#113791)
Browse files Browse the repository at this point in the history
This patch adds the `tgamma` libcall.
  • Loading branch information
c8ef authored Oct 29, 2024
1 parent 6128ff6 commit 0c1c37b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
15 changes: 15 additions & 0 deletions llvm/include/llvm/Analysis/TargetLibraryInfo.def
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,21 @@ TLI_DEFINE_ENUM_INTERNAL(erfl)
TLI_DEFINE_STRING_INTERNAL("erfl")
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)

/// double tgamma(double x);
TLI_DEFINE_ENUM_INTERNAL(tgamma)
TLI_DEFINE_STRING_INTERNAL("tgamma")
TLI_DEFINE_SIG_INTERNAL(Dbl, Dbl)

/// float tgammaf(float x);
TLI_DEFINE_ENUM_INTERNAL(tgammaf)
TLI_DEFINE_STRING_INTERNAL("tgammaf")
TLI_DEFINE_SIG_INTERNAL(Flt, Flt)

/// long double tgammal(long double x);
TLI_DEFINE_ENUM_INTERNAL(tgammal)
TLI_DEFINE_STRING_INTERNAL("tgammal")
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)

/// int execl(const char *path, const char *arg, ...);
TLI_DEFINE_ENUM_INTERNAL(execl)
TLI_DEFINE_STRING_INTERNAL("execl")
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/Utils/BuildLibCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
case LibFunc_erf:
case LibFunc_erff:
case LibFunc_erfl:
case LibFunc_tgamma:
case LibFunc_tgammaf:
case LibFunc_tgammal:
case LibFunc_exp:
case LibFunc_expf:
case LibFunc_expl:
Expand Down
9 changes: 9 additions & 0 deletions llvm/test/Transforms/InferFunctionAttrs/annotate.ll
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,15 @@ declare float @logf(float)
; CHECK: declare x86_fp80 @logl(x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
declare x86_fp80 @logl(x86_fp80)

; CHECK: declare double @tgamma(double) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
declare double @tgamma(double)

; CHECK: declare float @tgammaf(float) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
declare float @tgammaf(float)

; CHECK: declare x86_fp80 @tgammal(x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
declare x86_fp80 @tgammal(x86_fp80)

; CHECK: declare noundef i32 @lstat(ptr nocapture noundef readonly, ptr nocapture noundef) [[NOFREE_NOUNWIND]]
declare i32 @lstat(ptr, ptr)

Expand Down
20 changes: 16 additions & 4 deletions llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#
# CHECK: << Total TLI yes SDK no: 18
# CHECK: >> Total TLI no SDK yes: 0
# CHECK: == Total TLI yes SDK yes: 265
# CHECK: == Total TLI yes SDK yes: 268
#
# WRONG_DETAIL: << TLI yes SDK no : '_ZdaPv' aka operator delete[](void*)
# WRONG_DETAIL: >> TLI no SDK yes: '_ZdaPvj' aka operator delete[](void*, unsigned int)
Expand All @@ -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: 264
# WRONG_SUMMARY: == Total TLI yes SDK yes: 267
#
## 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 516 symbols, 283 available
# AVAIL-COUNT-283: {{^}} available
# AVAIL: TLI knows 519 symbols, 286 available
# AVAIL-COUNT-286: {{^}} available
# AVAIL-NOT: {{^}} available
# UNAVAIL-COUNT-233: not available
# UNAVAIL-NOT: not available
Expand Down Expand Up @@ -390,6 +390,18 @@ DynamicSymbols:
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: tgamma
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: tgammaf
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: tgammal
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: exp
Type: STT_FUNC
Section: .text
Expand Down
3 changes: 3 additions & 0 deletions llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
"declare double @erf(double)\n"
"declare float @erff(float)\n"
"declare x86_fp80 @erfl(x86_fp80)\n"
"declare double @tgamma(double)\n"
"declare float @tgammaf(float)\n"
"declare x86_fp80 @tgammal(x86_fp80)\n"
"declare i32 @printf(i8*, ...)\n"
"declare i32 @putc(i32, %struct*)\n"
"declare i32 @putc_unlocked(i32, %struct*)\n"
Expand Down

0 comments on commit 0c1c37b

Please sign in to comment.