Skip to content

Commit cd0926d

Browse files
serge-sans-paillezmodem
authored andcommitted
No longer generate calls to *_finite
According to Joseph Myers, a libm maintainer > They were only ever an ABI (selected by use of -ffinite-math-only or > options implying it, which resulted in the headers using "asm" to redirect > calls to some libm functions), not an API. The change means that ABI has > turned into compat symbols (only available for existing binaries, not for > anything newly linked, not included in static libm at all, not included in > shared libm for future glibc ports such as RV32), so, yes, in any case > where tools generate direct calls to those functions (rather than just > following the "asm" annotations on function declarations in the headers), > they need to stop doing so. As a consequence, we should no longer assume these symbols are available on the target system. Still keep the TargetLibraryInfo for constant folding. Differential Revision: https://reviews.llvm.org/D74712 (cherry picked from commit 6d15c4d) For https://bugs.llvm.org/show_bug.cgi?id=45034
1 parent 7cb6829 commit cd0926d

File tree

4 files changed

+45
-91
lines changed

4 files changed

+45
-91
lines changed

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
470470
TLI.setUnavailable(LibFunc_tmpfile64);
471471

472472
// Relaxed math functions are included in math-finite.h on Linux (GLIBC).
473+
// Note that math-finite.h is no longer supported by top-of-tree GLIBC,
474+
// so we keep these functions around just so that they're recognized by
475+
// the ConstantFolder.
473476
TLI.setUnavailable(LibFunc_acos_finite);
474477
TLI.setUnavailable(LibFunc_acosf_finite);
475478
TLI.setUnavailable(LibFunc_acosl_finite);

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3867,7 +3867,6 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
38673867
SmallVector<SDValue, 8> Results;
38683868
SDLoc dl(Node);
38693869
// FIXME: Check flags on the node to see if we can use a finite call.
3870-
bool CanUseFiniteLibCall = TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath;
38713870
unsigned Opc = Node->getOpcode();
38723871
switch (Opc) {
38733872
case ISD::ATOMIC_FENCE: {
@@ -3976,68 +3975,28 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
39763975
break;
39773976
case ISD::FLOG:
39783977
case ISD::STRICT_FLOG:
3979-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log_finite))
3980-
ExpandFPLibCall(Node, RTLIB::LOG_FINITE_F32,
3981-
RTLIB::LOG_FINITE_F64,
3982-
RTLIB::LOG_FINITE_F80,
3983-
RTLIB::LOG_FINITE_F128,
3984-
RTLIB::LOG_FINITE_PPCF128, Results);
3985-
else
3986-
ExpandFPLibCall(Node, RTLIB::LOG_F32, RTLIB::LOG_F64,
3987-
RTLIB::LOG_F80, RTLIB::LOG_F128,
3988-
RTLIB::LOG_PPCF128, Results);
3978+
ExpandFPLibCall(Node, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80,
3979+
RTLIB::LOG_F128, RTLIB::LOG_PPCF128, Results);
39893980
break;
39903981
case ISD::FLOG2:
39913982
case ISD::STRICT_FLOG2:
3992-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log2_finite))
3993-
ExpandFPLibCall(Node, RTLIB::LOG2_FINITE_F32,
3994-
RTLIB::LOG2_FINITE_F64,
3995-
RTLIB::LOG2_FINITE_F80,
3996-
RTLIB::LOG2_FINITE_F128,
3997-
RTLIB::LOG2_FINITE_PPCF128, Results);
3998-
else
3999-
ExpandFPLibCall(Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64,
4000-
RTLIB::LOG2_F80, RTLIB::LOG2_F128,
4001-
RTLIB::LOG2_PPCF128, Results);
3983+
ExpandFPLibCall(Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80,
3984+
RTLIB::LOG2_F128, RTLIB::LOG2_PPCF128, Results);
40023985
break;
40033986
case ISD::FLOG10:
40043987
case ISD::STRICT_FLOG10:
4005-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log10_finite))
4006-
ExpandFPLibCall(Node, RTLIB::LOG10_FINITE_F32,
4007-
RTLIB::LOG10_FINITE_F64,
4008-
RTLIB::LOG10_FINITE_F80,
4009-
RTLIB::LOG10_FINITE_F128,
4010-
RTLIB::LOG10_FINITE_PPCF128, Results);
4011-
else
4012-
ExpandFPLibCall(Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64,
4013-
RTLIB::LOG10_F80, RTLIB::LOG10_F128,
4014-
RTLIB::LOG10_PPCF128, Results);
3988+
ExpandFPLibCall(Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64, RTLIB::LOG10_F80,
3989+
RTLIB::LOG10_F128, RTLIB::LOG10_PPCF128, Results);
40153990
break;
40163991
case ISD::FEXP:
40173992
case ISD::STRICT_FEXP:
4018-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_exp_finite))
4019-
ExpandFPLibCall(Node, RTLIB::EXP_FINITE_F32,
4020-
RTLIB::EXP_FINITE_F64,
4021-
RTLIB::EXP_FINITE_F80,
4022-
RTLIB::EXP_FINITE_F128,
4023-
RTLIB::EXP_FINITE_PPCF128, Results);
4024-
else
4025-
ExpandFPLibCall(Node, RTLIB::EXP_F32, RTLIB::EXP_F64,
4026-
RTLIB::EXP_F80, RTLIB::EXP_F128,
4027-
RTLIB::EXP_PPCF128, Results);
3993+
ExpandFPLibCall(Node, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80,
3994+
RTLIB::EXP_F128, RTLIB::EXP_PPCF128, Results);
40283995
break;
40293996
case ISD::FEXP2:
40303997
case ISD::STRICT_FEXP2:
4031-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_exp2_finite))
4032-
ExpandFPLibCall(Node, RTLIB::EXP2_FINITE_F32,
4033-
RTLIB::EXP2_FINITE_F64,
4034-
RTLIB::EXP2_FINITE_F80,
4035-
RTLIB::EXP2_FINITE_F128,
4036-
RTLIB::EXP2_FINITE_PPCF128, Results);
4037-
else
4038-
ExpandFPLibCall(Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64,
4039-
RTLIB::EXP2_F80, RTLIB::EXP2_F128,
4040-
RTLIB::EXP2_PPCF128, Results);
3998+
ExpandFPLibCall(Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80,
3999+
RTLIB::EXP2_F128, RTLIB::EXP2_PPCF128, Results);
40414000
break;
40424001
case ISD::FTRUNC:
40434002
case ISD::STRICT_FTRUNC:
@@ -4107,16 +4066,8 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
41074066
}
41084067
case ISD::FPOW:
41094068
case ISD::STRICT_FPOW:
4110-
if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_pow_finite))
4111-
ExpandFPLibCall(Node, RTLIB::POW_FINITE_F32,
4112-
RTLIB::POW_FINITE_F64,
4113-
RTLIB::POW_FINITE_F80,
4114-
RTLIB::POW_FINITE_F128,
4115-
RTLIB::POW_FINITE_PPCF128, Results);
4116-
else
4117-
ExpandFPLibCall(Node, RTLIB::POW_F32, RTLIB::POW_F64,
4118-
RTLIB::POW_F80, RTLIB::POW_F128,
4119-
RTLIB::POW_PPCF128, Results);
4069+
ExpandFPLibCall(Node, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80,
4070+
RTLIB::POW_F128, RTLIB::POW_PPCF128, Results);
41204071
break;
41214072
case ISD::LROUND:
41224073
case ISD::STRICT_LROUND:

llvm/test/CodeGen/AArch64/illegal-float-ops.ll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
2-
; RUN: llc -mtriple=aarch64-linux-android -verify-machineinstrs -o - %s | FileCheck --check-prefix=ANDROID-AARCH64 %s
2+
; RUN: llc -mtriple=aarch64-linux-android -verify-machineinstrs -o - %s | FileCheck %s
33

44
@varfloat = global float 0.0
55
@vardouble = global double 0.0
@@ -299,49 +299,49 @@ define void @test_exp_finite(double %double) #0 {
299299
%expdouble = call double @llvm.exp.f64(double %double)
300300
store double %expdouble, double* @vardouble
301301
; ANDROID-AARCH64-NOT: bl __exp_finite
302-
; CHECK: bl __exp_finite
302+
; CHECK: bl exp
303303

304304
ret void
305305
}
306306

307307
define void @test_exp2_finite(double %double) #0 {
308308
%expdouble = call double @llvm.exp2.f64(double %double)
309309
store double %expdouble, double* @vardouble
310-
; ANDROID-AARCH64-NOT: bl __exp2_finite
311-
; CHECK: bl __exp2_finite
310+
; CHECK-NOT: bl __exp2_finite
311+
; CHECK: bl exp2
312312

313313
ret void
314314
}
315315

316316
define void @test_log_finite(double %double) #0 {
317317
%logdouble = call double @llvm.log.f64(double %double)
318318
store double %logdouble, double* @vardouble
319-
; ANDROID-AARCH64-NOT: bl __log_finite
320-
; CHECK: bl __log_finite
319+
; CHECK-NOT: bl __log_finite
320+
; CHECK: bl log
321321
ret void
322322
}
323323

324324
define void @test_log2_finite(double %double) #0 {
325325
%log2double = call double @llvm.log2.f64(double %double)
326326
store double %log2double, double* @vardouble
327-
; ANDROID-AARCH64-NOT: bl __log2_finite
328-
; CHECK: bl __log2_finite
327+
; CHECK-NOT: bl __log2_finite
328+
; CHECK: bl log2
329329
ret void
330330
}
331331

332332
define void @test_log10_finite(double %double) #0 {
333333
%log10double = call double @llvm.log10.f64(double %double)
334334
store double %log10double, double* @vardouble
335-
; ANDROID-AARCH64-NOT: bl __log10_finite
336-
; CHECK: bl __log10_finite
335+
; CHECK-NOT: bl __log10_finite
336+
; CHECK: bl log10
337337
ret void
338338
}
339339

340340
define void @test_pow_finite(double %double) #0 {
341341
%powdouble = call double @llvm.pow.f64(double %double, double %double)
342342
store double %powdouble, double* @vardouble
343-
; ANDROID-AARCH64-NOT: bl __pow_finite
344-
; CHECK: bl __pow_finite
343+
; CHECK-NOT: bl __pow_finite
344+
; CHECK: bl pow
345345
ret void
346346
}
347347

llvm/test/CodeGen/X86/finite-libcalls.ll

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
define float @exp_f32(float %x) #0 {
1010
; GNU-LABEL: exp_f32:
1111
; GNU: # %bb.0:
12-
; GNU-NEXT: jmp __expf_finite # TAILCALL
12+
; GNU-NEXT: jmp expf # TAILCALL
1313
;
1414
; WIN-LABEL: exp_f32:
1515
; WIN: # %bb.0:
@@ -25,7 +25,7 @@ define float @exp_f32(float %x) #0 {
2525
define double @exp_f64(double %x) #0 {
2626
; GNU-LABEL: exp_f64:
2727
; GNU: # %bb.0:
28-
; GNU-NEXT: jmp __exp_finite # TAILCALL
28+
; GNU-NEXT: jmp exp # TAILCALL
2929
;
3030
; WIN-LABEL: exp_f64:
3131
; WIN: # %bb.0:
@@ -44,7 +44,7 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 {
4444
; GNU-NEXT: subq $24, %rsp
4545
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
4646
; GNU-NEXT: fstpt (%rsp)
47-
; GNU-NEXT: callq __expl_finite
47+
; GNU-NEXT: callq expl
4848
; GNU-NEXT: addq $24, %rsp
4949
; GNU-NEXT: retq
5050
;
@@ -80,7 +80,7 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 {
8080
define float @exp2_f32(float %x) #0 {
8181
; GNU-LABEL: exp2_f32:
8282
; GNU: # %bb.0:
83-
; GNU-NEXT: jmp __exp2f_finite # TAILCALL
83+
; GNU-NEXT: jmp exp2f # TAILCALL
8484
;
8585
; WIN-LABEL: exp2_f32:
8686
; WIN: # %bb.0:
@@ -96,7 +96,7 @@ define float @exp2_f32(float %x) #0 {
9696
define double @exp2_f64(double %x) #0 {
9797
; GNU-LABEL: exp2_f64:
9898
; GNU: # %bb.0:
99-
; GNU-NEXT: jmp __exp2_finite # TAILCALL
99+
; GNU-NEXT: jmp exp2 # TAILCALL
100100
;
101101
; WIN-LABEL: exp2_f64:
102102
; WIN: # %bb.0:
@@ -115,7 +115,7 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 {
115115
; GNU-NEXT: subq $24, %rsp
116116
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
117117
; GNU-NEXT: fstpt (%rsp)
118-
; GNU-NEXT: callq __exp2l_finite
118+
; GNU-NEXT: callq exp2l
119119
; GNU-NEXT: addq $24, %rsp
120120
; GNU-NEXT: retq
121121
;
@@ -151,7 +151,7 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 {
151151
define float @log_f32(float %x) #0 {
152152
; GNU-LABEL: log_f32:
153153
; GNU: # %bb.0:
154-
; GNU-NEXT: jmp __logf_finite # TAILCALL
154+
; GNU-NEXT: jmp logf # TAILCALL
155155
;
156156
; WIN-LABEL: log_f32:
157157
; WIN: # %bb.0:
@@ -167,7 +167,7 @@ define float @log_f32(float %x) #0 {
167167
define double @log_f64(double %x) #0 {
168168
; GNU-LABEL: log_f64:
169169
; GNU: # %bb.0:
170-
; GNU-NEXT: jmp __log_finite # TAILCALL
170+
; GNU-NEXT: jmp log # TAILCALL
171171
;
172172
; WIN-LABEL: log_f64:
173173
; WIN: # %bb.0:
@@ -186,7 +186,7 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 {
186186
; GNU-NEXT: subq $24, %rsp
187187
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
188188
; GNU-NEXT: fstpt (%rsp)
189-
; GNU-NEXT: callq __logl_finite
189+
; GNU-NEXT: callq logl
190190
; GNU-NEXT: addq $24, %rsp
191191
; GNU-NEXT: retq
192192
;
@@ -222,7 +222,7 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 {
222222
define float @log2_f32(float %x) #0 {
223223
; GNU-LABEL: log2_f32:
224224
; GNU: # %bb.0:
225-
; GNU-NEXT: jmp __log2f_finite # TAILCALL
225+
; GNU-NEXT: jmp log2f # TAILCALL
226226
;
227227
; WIN-LABEL: log2_f32:
228228
; WIN: # %bb.0:
@@ -238,7 +238,7 @@ define float @log2_f32(float %x) #0 {
238238
define double @log2_f64(double %x) #0 {
239239
; GNU-LABEL: log2_f64:
240240
; GNU: # %bb.0:
241-
; GNU-NEXT: jmp __log2_finite # TAILCALL
241+
; GNU-NEXT: jmp log2 # TAILCALL
242242
;
243243
; WIN-LABEL: log2_f64:
244244
; WIN: # %bb.0:
@@ -257,7 +257,7 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 {
257257
; GNU-NEXT: subq $24, %rsp
258258
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
259259
; GNU-NEXT: fstpt (%rsp)
260-
; GNU-NEXT: callq __log2l_finite
260+
; GNU-NEXT: callq log2l
261261
; GNU-NEXT: addq $24, %rsp
262262
; GNU-NEXT: retq
263263
;
@@ -293,7 +293,7 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 {
293293
define float @log10_f32(float %x) #0 {
294294
; GNU-LABEL: log10_f32:
295295
; GNU: # %bb.0:
296-
; GNU-NEXT: jmp __log10f_finite # TAILCALL
296+
; GNU-NEXT: jmp log10f # TAILCALL
297297
;
298298
; WIN-LABEL: log10_f32:
299299
; WIN: # %bb.0:
@@ -309,7 +309,7 @@ define float @log10_f32(float %x) #0 {
309309
define double @log10_f64(double %x) #0 {
310310
; GNU-LABEL: log10_f64:
311311
; GNU: # %bb.0:
312-
; GNU-NEXT: jmp __log10_finite # TAILCALL
312+
; GNU-NEXT: jmp log10 # TAILCALL
313313
;
314314
; WIN-LABEL: log10_f64:
315315
; WIN: # %bb.0:
@@ -328,7 +328,7 @@ define x86_fp80 @log10_f80(x86_fp80 %x) #0 {
328328
; GNU-NEXT: subq $24, %rsp
329329
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
330330
; GNU-NEXT: fstpt (%rsp)
331-
; GNU-NEXT: callq __log10l_finite
331+
; GNU-NEXT: callq log10l
332332
; GNU-NEXT: addq $24, %rsp
333333
; GNU-NEXT: retq
334334
;
@@ -365,7 +365,7 @@ define float @pow_f32(float %x) #0 {
365365
; GNU-LABEL: pow_f32:
366366
; GNU: # %bb.0:
367367
; GNU-NEXT: movaps %xmm0, %xmm1
368-
; GNU-NEXT: jmp __powf_finite # TAILCALL
368+
; GNU-NEXT: jmp powf # TAILCALL
369369
;
370370
; WIN-LABEL: pow_f32:
371371
; WIN: # %bb.0:
@@ -384,7 +384,7 @@ define double @pow_f64(double %x) #0 {
384384
; GNU-LABEL: pow_f64:
385385
; GNU: # %bb.0:
386386
; GNU-NEXT: movaps %xmm0, %xmm1
387-
; GNU-NEXT: jmp __pow_finite # TAILCALL
387+
; GNU-NEXT: jmp pow # TAILCALL
388388
;
389389
; WIN-LABEL: pow_f64:
390390
; WIN: # %bb.0:
@@ -407,7 +407,7 @@ define x86_fp80 @pow_f80(x86_fp80 %x) #0 {
407407
; GNU-NEXT: fld %st(0)
408408
; GNU-NEXT: fstpt {{[0-9]+}}(%rsp)
409409
; GNU-NEXT: fstpt (%rsp)
410-
; GNU-NEXT: callq __powl_finite
410+
; GNU-NEXT: callq powl
411411
; GNU-NEXT: addq $40, %rsp
412412
; GNU-NEXT: retq
413413
;

0 commit comments

Comments
 (0)