Skip to content

Commit 9f0ccdd

Browse files
committed
RuntimeLibcalls: Stop opting out of exp10
This changes the behavior on old darwin triples for x86_fp80; it now turns into an error instead of emitting exp10l. The comments in TargetLibraryInfo suggest it never existed.
1 parent 0991435 commit 9f0ccdd

File tree

6 files changed

+112
-68
lines changed

6 files changed

+112
-68
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def isNotOSWindowsOrIsCygwinMinGW
2929
def isGNUEnvironment : RuntimeLibcallPredicate<"TT.isGNUEnvironment()">;
3030
def darwinHasSinCosStret : RuntimeLibcallPredicate<"darwinHasSinCosStret(TT)">;
3131
def darwinHasExp10 : RuntimeLibcallPredicate<"darwinHasExp10(TT)">;
32+
33+
def hasExp10 : RuntimeLibcallPredicate<[{!TT.isOSDarwin()}]>;
34+
3235
def hasSinCos : RuntimeLibcallPredicate<"hasSinCos(TT)">;
3336

3437
// FIXME: Way to combine predicates
@@ -776,12 +779,6 @@ def __exp2l_finite_f80 : RuntimeLibcallImpl<EXP2_FINITE_F80, "__exp2l_finite">;
776779
def __exp2l_finite_f128 : RuntimeLibcallImpl<EXP2_FINITE_F128, "__exp2l_finite">;
777780
def __exp2l_finite_ppcf128 : RuntimeLibcallImpl<EXP2_FINITE_PPCF128, "__exp2l_finite">;
778781

779-
def exp10f : RuntimeLibcallImpl<EXP10_F32>;
780-
def exp10 : RuntimeLibcallImpl<EXP10_F64>;
781-
def exp10l_f80 : RuntimeLibcallImpl<EXP10_F80, "exp10l">;
782-
def exp10l_f128 : RuntimeLibcallImpl<EXP10_F128, "exp10l">;
783-
def exp10l_ppcf128 : RuntimeLibcallImpl<EXP10_PPCF128, "exp10l">;
784-
785782
def sinf : RuntimeLibcallImpl<SIN_F32>;
786783
def sin : RuntimeLibcallImpl<SIN_F64>;
787784
defm sin : LibmLongDoubleLibCall;
@@ -942,6 +939,12 @@ def calloc : RuntimeLibcallImpl<CALLOC>;
942939

943940
} // End let IsDefault = true
944941

942+
def exp10f : RuntimeLibcallImpl<EXP10_F32>;
943+
def exp10 : RuntimeLibcallImpl<EXP10_F64>;
944+
def exp10l_f80 : RuntimeLibcallImpl<EXP10_F80, "exp10l">;
945+
def exp10l_f128 : RuntimeLibcallImpl<EXP10_F128, "exp10l">;
946+
def exp10l_ppcf128 : RuntimeLibcallImpl<EXP10_PPCF128, "exp10l">;
947+
945948
//--------------------------------------------------------------------
946949
// compiler-rt/libgcc but 64-bit only, not available by default
947950
//--------------------------------------------------------------------
@@ -1097,6 +1100,12 @@ defvar LibmHasSinCosF80 = LibcallImpls<(add sincos_f80), hasSinCos>;
10971100
defvar LibmHasSinCosF128 = LibcallImpls<(add sincos_f128), hasSinCos>;
10981101
defvar LibmHasSinCosPPCF128 = LibcallImpls<(add sincos_ppcf128), hasSinCos>;
10991102

1103+
defvar LibmHasExp10F32 = LibcallImpls<(add exp10f), hasExp10>;
1104+
defvar LibmHasExp10F64 = LibcallImpls<(add exp10), hasExp10>;
1105+
defvar LibmHasExp10F80 = LibcallImpls<(add exp10l_f80), hasExp10>;
1106+
defvar LibmHasExp10F128 = LibcallImpls<(add exp10l_f128), hasExp10>;
1107+
defvar LibmHasExp10PPCF128 = LibcallImpls<(add exp10l_ppcf128), hasExp10>;
1108+
11001109
defvar WindowsMathRemovals = [
11011110
ldexpf, ldexp_f80, ldexp_f128, ldexp_ppcf128,
11021111
frexpf, frexp_f80, frexp_f128, frexp_ppcf128
@@ -1195,7 +1204,8 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
11951204
LibcallImpls<(add Int128RTLibcalls), isAArch64_ILP64>,
11961205
LibcallImpls<(add bzero), isOSDarwin>,
11971206
DarwinExp10, DarwinSinCosStret,
1198-
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128)
1207+
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1208+
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128)
11991209
>;
12001210

12011211
// Prepend a # to every name
@@ -1466,6 +1476,7 @@ def ARMSystemLibrary
14661476
AEABIDivRemCalls,
14671477
DarwinSinCosStret, DarwinExp10,
14681478
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1479+
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F128,
14691480

14701481
// Use divmod compiler-rt calls for iOS 5.0 and later.
14711482
LibcallImpls<(add __divmodsi4, __udivmodsi4),
@@ -1958,6 +1969,7 @@ def PPCSystemLibrary
19581969
DefaultRuntimeLibcallImpls_f128),
19591970
__extendkftf2, __trunctfkf2,
19601971
DefaultRuntimeLibcallImpls_ppcf128,
1972+
exp10f, exp10, exp10l_ppcf128,
19611973
LibmF128Libcalls, AIX32Calls, AIX64Calls,
19621974
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
19631975
LibmHasSinCosPPCF128,
@@ -1973,7 +1985,9 @@ def isRISCV64 : RuntimeLibcallPredicate<"TT.isRISCV64()">;
19731985

19741986
def RISCVSystemLibrary
19751987
: SystemRuntimeLibrary<isRISCV,
1976-
(add DefaultRuntimeLibcallImpls, __riscv_flush_icache,
1988+
(add DefaultRuntimeLibcallImpls,
1989+
exp10f, exp10, exp10l_f128,
1990+
__riscv_flush_icache,
19771991
LibcallImpls<(add Int128RTLibcalls), isRISCV64>)>;
19781992

19791993
//===----------------------------------------------------------------------===//
@@ -2068,7 +2082,7 @@ def isX86 : RuntimeLibcallPredicate<"TT.isX86()">;
20682082
def darwinHas__bzero : RuntimeLibcallPredicate<"TT.isMacOSX() && !TT.isMacOSXVersionLT(10, 6)">;
20692083

20702084
// FIXME: This is has ldexpl/frexpl plus use f128 for long double.
2071-
def hasFrexplLdexplF128
2085+
def hasExpFrexplLdexplF128
20722086
: RuntimeLibcallPredicate<[{(!TT.isOSWindows() || TT.isOSCygMing()) && !TT.isGNUEnvironment()}]>;
20732087

20742088
// Use the f128 variants of math functions on x86
@@ -2084,12 +2098,13 @@ defvar X86CommonLibcalls =
20842098
LibcallImpls<(add __bzero), darwinHas__bzero>,
20852099
LibmHasFrexpF32, LibmHasLdexpF32,
20862100
LibmHasFrexpF80, LibmHasLdexpF80,
2087-
LibcallImpls<(add frexp_f128, ldexp_f128), hasFrexplLdexplF128>,
2101+
LibcallImpls<(add frexp_f128, ldexp_f128, exp10l_f128), hasExpFrexplLdexplF128>,
20882102
DefaultRuntimeLibcallImpls_f80,
2103+
LibmHasExp10F32, LibmHasExp10F64, LibmHasExp10F80,
2104+
LibcallImpls<(add MostPowI), isNotOSMSVCRT>,
20892105
// FIXME: MSVCRT doesn't have powi. The f128 case is added as a
20902106
// hack for one test relying on it.
2091-
__powitf2_f128,
2092-
LibcallImpls<(add MostPowI), isNotOSMSVCRT>
2107+
__powitf2_f128
20932108
);
20942109

20952110
defvar Windows32DivRemMulCalls =
@@ -2229,4 +2244,5 @@ def WasmSystemLibrary
22292244
: SystemRuntimeLibrary<isWasm,
22302245
(add DefaultRuntimeLibcallImpls, Int128RTLibcalls,
22312246
CompilerRTOnlyInt64Libcalls, CompilerRTOnlyInt128Libcalls,
2247+
exp10f, exp10,
22322248
emscripten_return_address)>;

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
102102
setLibcallImpl(RTLIB::STACKPROTECTOR_CHECK_FAIL, RTLIB::Unsupported);
103103
}
104104

105-
// Skip default manual processing for targets that have been fully ported to
105+
// Skip default manual processing for targets that have been mostly ported to
106106
// tablegen for now. Eventually the rest of this should be deleted.
107-
if (TT.isX86() || TT.isAArch64() || TT.isWasm())
107+
if (TT.isX86() || TT.isAArch64() || TT.isWasm() || TT.isPPC())
108108
return;
109109

110110
if (TT.isARM() || TT.isThumb()) {
@@ -118,6 +118,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
118118
setLibcallImpl(RTLIB::SINCOS_F128, RTLIB::sincos_f128);
119119
}
120120

121+
setLibcallImpl(RTLIB::EXP10_F32, RTLIB::exp10f);
122+
setLibcallImpl(RTLIB::EXP10_F64, RTLIB::exp10);
123+
setLibcallImpl(RTLIB::EXP10_F128, RTLIB::exp10l_f128);
124+
121125
// These libcalls are only available in compiler-rt, not libgcc.
122126
if (TT.isArch64Bit()) {
123127
setLibcallImpl(RTLIB::SHL_I128, RTLIB::__ashlti3);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
2+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
3+
; RUN: %if aarch64-registered-target %{ llc < %s -mtriple=aarch64-unknown-none | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
4+
; RUN: %if aarch64-registered-target %{ not llc -mtriple=arm64-apple-macosx -filetype=null %s 2>&1 | FileCheck --check-prefix=ERR %s %}
5+
; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-none-eabi | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
6+
; RUN: %if arm-registered-target %{ llc < %s -mtriple=arm-unknown-linux-gnueabi | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
7+
; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
8+
; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
9+
; RUN: %if powerpc-registered-target %{ llc < %s -mtriple=powerpc64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
10+
; RUN: %if riscv-registered-target %{ llc < %s -mtriple=riscv32-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
11+
; RUN: %if systemz-registered-target %{ llc < %s -mtriple=s390x-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-S390X %}
12+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
13+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=i686-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
14+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
15+
; RUN: %if x86-registered-target %{ llc < %s -mtriple=x86_64-unknown-linux-musl | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-USELD %}
16+
;
17+
; FIXME(#144006): Windows-MSVC should also be run but has a ldexp selection
18+
; failure.
19+
; %if x86-registered-target %{ llc < %s -mtriple=x86_64-pc-windows-msvc -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-F128 %}
20+
21+
; ERR: error: no libcall available for fexp10
22+
define fp128 @test_exp10(fp128 %a) {
23+
; CHECK-ALL-LABEL: test_exp10:
24+
; CHECK-F128: exp10f128
25+
; CHECK-USELD: exp10l
26+
; CHECK-S390X: exp10l
27+
start:
28+
%0 = tail call fp128 @llvm.exp10.f128(fp128 %a)
29+
ret fp128 %0
30+
}
31+

llvm/test/CodeGen/Generic/fp128-math-libcalls.ll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,6 @@ start:
9595
ret fp128 %0
9696
}
9797

98-
define fp128 @test_exp10(fp128 %a) {
99-
; CHECK-ALL-LABEL: test_exp10:
100-
; CHECK-F128: exp10f128
101-
; CHECK-USELD: exp10l
102-
; CHECK-S390X: exp10l
103-
start:
104-
%0 = tail call fp128 @llvm.exp10.f128(fp128 %a)
105-
ret fp128 %0
106-
}
107-
10898
define fp128 @test_exp2(fp128 %a) {
10999
; CHECK-ALL-LABEL: test_exp2:
110100
; CHECK-F128: exp2f128

llvm/test/CodeGen/X86/exp10-libcall-names.ll

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X86
1414
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X64
1515

16-
; RUN: not llc -mtriple=x86_64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
17-
; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted systems.
18-
19-
; ERR: no libcall available for fexp10
16+
; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted darwin systems.
2017

2118
define float @test_exp10_f32(float %x) nounwind {
2219
; LINUX-LABEL: test_exp10_f32:
@@ -78,43 +75,3 @@ define double @test_exp10_f64(double %x) nounwind {
7875
%ret = call double @llvm.exp10.f64(double %x)
7976
ret double %ret
8077
}
81-
82-
define x86_fp80 @test_exp10_f80(x86_fp80 %x) nounwind {
83-
; LINUX-LABEL: test_exp10_f80:
84-
; LINUX: # %bb.0:
85-
; LINUX-NEXT: subq $24, %rsp
86-
; LINUX-NEXT: fldt {{[0-9]+}}(%rsp)
87-
; LINUX-NEXT: fstpt (%rsp)
88-
; LINUX-NEXT: callq exp10l@PLT
89-
; LINUX-NEXT: addq $24, %rsp
90-
; LINUX-NEXT: retq
91-
;
92-
; APPLE-LABEL: test_exp10_f80:
93-
; APPLE: ## %bb.0:
94-
; APPLE-NEXT: subq $24, %rsp
95-
; APPLE-NEXT: fldt {{[0-9]+}}(%rsp)
96-
; APPLE-NEXT: fstpt (%rsp)
97-
; APPLE-NEXT: callq _exp10l
98-
; APPLE-NEXT: addq $24, %rsp
99-
; APPLE-NEXT: retq
100-
;
101-
; GISEL-X86-LABEL: test_exp10_f80:
102-
; GISEL-X86: # %bb.0:
103-
; GISEL-X86-NEXT: subl $12, %esp
104-
; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
105-
; GISEL-X86-NEXT: fstpt (%esp)
106-
; GISEL-X86-NEXT: calll exp10l
107-
; GISEL-X86-NEXT: addl $12, %esp
108-
; GISEL-X86-NEXT: retl
109-
;
110-
; GISEL-X64-LABEL: test_exp10_f80:
111-
; GISEL-X64: # %bb.0:
112-
; GISEL-X64-NEXT: subq $24, %rsp
113-
; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
114-
; GISEL-X64-NEXT: fstpt (%rsp)
115-
; GISEL-X64-NEXT: callq exp10l
116-
; GISEL-X64-NEXT: addq $24, %rsp
117-
; GISEL-X64-NEXT: retq
118-
%ret = call x86_fp80 @llvm.exp10.f80(x86_fp80 %x)
119-
ret x86_fp80 %ret
120-
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck -check-prefix=LINUX %s
2+
; RUN: not llc -mtriple=x86_64-apple-macos10.9 < %s 2>&1 | FileCheck -check-prefix=ERR %s
3+
; RUN: not llc -mtriple=x86_64-apple-ios9.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
4+
; RUN: not llc -mtriple=x86_64-apple-tvos9.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
5+
; RUN: not llc -mtriple=x86_64-apple-watchos9.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
6+
; RUN: not llc -mtriple=x86_64-apple-xros9.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
7+
; RUN: not llc -mtriple=x86_64-apple-ios8.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
8+
; RUN: not llc -mtriple=x86_64-apple-tvos8.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
9+
; RUN: not llc -mtriple=x86_64-apple-xros8.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
10+
; RUN: not llc -mtriple=x86_64-apple-driverkit < %s 2>&1 | FileCheck -check-prefix=ERR %s
11+
; RUN: not llc -mtriple=x86_64-apple-driverkit24.0 < %s 2>&1 | FileCheck -check-prefix=ERR %s
12+
; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X86
13+
; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefix=GISEL-X64
14+
15+
; ERR: no libcall available for fexp10
16+
17+
define x86_fp80 @test_exp10_f80(x86_fp80 %x) nounwind {
18+
; LINUX-LABEL: test_exp10_f80:
19+
; LINUX: # %bb.0:
20+
; LINUX-NEXT: subq $24, %rsp
21+
; LINUX-NEXT: fldt {{[0-9]+}}(%rsp)
22+
; LINUX-NEXT: fstpt (%rsp)
23+
; LINUX-NEXT: callq exp10l@PLT
24+
; LINUX-NEXT: addq $24, %rsp
25+
; LINUX-NEXT: retq
26+
;
27+
; GISEL-X86-LABEL: test_exp10_f80:
28+
; GISEL-X86: # %bb.0:
29+
; GISEL-X86-NEXT: subl $12, %esp
30+
; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp)
31+
; GISEL-X86-NEXT: fstpt (%esp)
32+
; GISEL-X86-NEXT: calll exp10l
33+
; GISEL-X86-NEXT: addl $12, %esp
34+
; GISEL-X86-NEXT: retl
35+
;
36+
; GISEL-X64-LABEL: test_exp10_f80:
37+
; GISEL-X64: # %bb.0:
38+
; GISEL-X64-NEXT: subq $24, %rsp
39+
; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
40+
; GISEL-X64-NEXT: fstpt (%rsp)
41+
; GISEL-X64-NEXT: callq exp10l
42+
; GISEL-X64-NEXT: addq $24, %rsp
43+
; GISEL-X64-NEXT: retq
44+
%ret = call x86_fp80 @llvm.exp10.f80(x86_fp80 %x)
45+
ret x86_fp80 %ret
46+
}

0 commit comments

Comments
 (0)