[llvm-branch-commits] [llvm] cd0926d - No longer generate calls to *_finite
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 28 03:00:31 PST 2020
Author: serge-sans-paille
Date: 2020-02-28T11:52:11+01:00
New Revision: cd0926d087a85c5ee1222ca80980b4440214a822
URL: https://github.com/llvm/llvm-project/commit/cd0926d087a85c5ee1222ca80980b4440214a822
DIFF: https://github.com/llvm/llvm-project/commit/cd0926d087a85c5ee1222ca80980b4440214a822.diff
LOG: 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 6d15c4deab51498b70825fb6cefbbfe8f3d9bdcf)
For https://bugs.llvm.org/show_bug.cgi?id=45034
Added:
Modified:
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/test/CodeGen/AArch64/illegal-float-ops.ll
llvm/test/CodeGen/X86/finite-libcalls.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index c7238db43aab..1a32adf4723a 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -470,6 +470,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_tmpfile64);
// Relaxed math functions are included in math-finite.h on Linux (GLIBC).
+ // Note that math-finite.h is no longer supported by top-of-tree GLIBC,
+ // so we keep these functions around just so that they're recognized by
+ // the ConstantFolder.
TLI.setUnavailable(LibFunc_acos_finite);
TLI.setUnavailable(LibFunc_acosf_finite);
TLI.setUnavailable(LibFunc_acosl_finite);
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 80ac8b95e4ef..91404ee7728b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3867,7 +3867,6 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
SmallVector<SDValue, 8> Results;
SDLoc dl(Node);
// FIXME: Check flags on the node to see if we can use a finite call.
- bool CanUseFiniteLibCall = TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath;
unsigned Opc = Node->getOpcode();
switch (Opc) {
case ISD::ATOMIC_FENCE: {
@@ -3976,68 +3975,28 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
break;
case ISD::FLOG:
case ISD::STRICT_FLOG:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log_finite))
- ExpandFPLibCall(Node, RTLIB::LOG_FINITE_F32,
- RTLIB::LOG_FINITE_F64,
- RTLIB::LOG_FINITE_F80,
- RTLIB::LOG_FINITE_F128,
- RTLIB::LOG_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::LOG_F32, RTLIB::LOG_F64,
- RTLIB::LOG_F80, RTLIB::LOG_F128,
- RTLIB::LOG_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::LOG_F32, RTLIB::LOG_F64, RTLIB::LOG_F80,
+ RTLIB::LOG_F128, RTLIB::LOG_PPCF128, Results);
break;
case ISD::FLOG2:
case ISD::STRICT_FLOG2:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log2_finite))
- ExpandFPLibCall(Node, RTLIB::LOG2_FINITE_F32,
- RTLIB::LOG2_FINITE_F64,
- RTLIB::LOG2_FINITE_F80,
- RTLIB::LOG2_FINITE_F128,
- RTLIB::LOG2_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64,
- RTLIB::LOG2_F80, RTLIB::LOG2_F128,
- RTLIB::LOG2_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::LOG2_F32, RTLIB::LOG2_F64, RTLIB::LOG2_F80,
+ RTLIB::LOG2_F128, RTLIB::LOG2_PPCF128, Results);
break;
case ISD::FLOG10:
case ISD::STRICT_FLOG10:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_log10_finite))
- ExpandFPLibCall(Node, RTLIB::LOG10_FINITE_F32,
- RTLIB::LOG10_FINITE_F64,
- RTLIB::LOG10_FINITE_F80,
- RTLIB::LOG10_FINITE_F128,
- RTLIB::LOG10_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64,
- RTLIB::LOG10_F80, RTLIB::LOG10_F128,
- RTLIB::LOG10_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::LOG10_F32, RTLIB::LOG10_F64, RTLIB::LOG10_F80,
+ RTLIB::LOG10_F128, RTLIB::LOG10_PPCF128, Results);
break;
case ISD::FEXP:
case ISD::STRICT_FEXP:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_exp_finite))
- ExpandFPLibCall(Node, RTLIB::EXP_FINITE_F32,
- RTLIB::EXP_FINITE_F64,
- RTLIB::EXP_FINITE_F80,
- RTLIB::EXP_FINITE_F128,
- RTLIB::EXP_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::EXP_F32, RTLIB::EXP_F64,
- RTLIB::EXP_F80, RTLIB::EXP_F128,
- RTLIB::EXP_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::EXP_F32, RTLIB::EXP_F64, RTLIB::EXP_F80,
+ RTLIB::EXP_F128, RTLIB::EXP_PPCF128, Results);
break;
case ISD::FEXP2:
case ISD::STRICT_FEXP2:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_exp2_finite))
- ExpandFPLibCall(Node, RTLIB::EXP2_FINITE_F32,
- RTLIB::EXP2_FINITE_F64,
- RTLIB::EXP2_FINITE_F80,
- RTLIB::EXP2_FINITE_F128,
- RTLIB::EXP2_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64,
- RTLIB::EXP2_F80, RTLIB::EXP2_F128,
- RTLIB::EXP2_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::EXP2_F32, RTLIB::EXP2_F64, RTLIB::EXP2_F80,
+ RTLIB::EXP2_F128, RTLIB::EXP2_PPCF128, Results);
break;
case ISD::FTRUNC:
case ISD::STRICT_FTRUNC:
@@ -4107,16 +4066,8 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) {
}
case ISD::FPOW:
case ISD::STRICT_FPOW:
- if (CanUseFiniteLibCall && DAG.getLibInfo().has(LibFunc_pow_finite))
- ExpandFPLibCall(Node, RTLIB::POW_FINITE_F32,
- RTLIB::POW_FINITE_F64,
- RTLIB::POW_FINITE_F80,
- RTLIB::POW_FINITE_F128,
- RTLIB::POW_FINITE_PPCF128, Results);
- else
- ExpandFPLibCall(Node, RTLIB::POW_F32, RTLIB::POW_F64,
- RTLIB::POW_F80, RTLIB::POW_F128,
- RTLIB::POW_PPCF128, Results);
+ ExpandFPLibCall(Node, RTLIB::POW_F32, RTLIB::POW_F64, RTLIB::POW_F80,
+ RTLIB::POW_F128, RTLIB::POW_PPCF128, Results);
break;
case ISD::LROUND:
case ISD::STRICT_LROUND:
diff --git a/llvm/test/CodeGen/AArch64/illegal-float-ops.ll b/llvm/test/CodeGen/AArch64/illegal-float-ops.ll
index ffa813e09c73..5f24cd4bf637 100644
--- a/llvm/test/CodeGen/AArch64/illegal-float-ops.ll
+++ b/llvm/test/CodeGen/AArch64/illegal-float-ops.ll
@@ -1,5 +1,5 @@
; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
-; RUN: llc -mtriple=aarch64-linux-android -verify-machineinstrs -o - %s | FileCheck --check-prefix=ANDROID-AARCH64 %s
+; RUN: llc -mtriple=aarch64-linux-android -verify-machineinstrs -o - %s | FileCheck %s
@varfloat = global float 0.0
@vardouble = global double 0.0
@@ -299,7 +299,7 @@ define void @test_exp_finite(double %double) #0 {
%expdouble = call double @llvm.exp.f64(double %double)
store double %expdouble, double* @vardouble
; ANDROID-AARCH64-NOT: bl __exp_finite
- ; CHECK: bl __exp_finite
+ ; CHECK: bl exp
ret void
}
@@ -307,8 +307,8 @@ define void @test_exp_finite(double %double) #0 {
define void @test_exp2_finite(double %double) #0 {
%expdouble = call double @llvm.exp2.f64(double %double)
store double %expdouble, double* @vardouble
- ; ANDROID-AARCH64-NOT: bl __exp2_finite
- ; CHECK: bl __exp2_finite
+ ; CHECK-NOT: bl __exp2_finite
+ ; CHECK: bl exp2
ret void
}
@@ -316,32 +316,32 @@ define void @test_exp2_finite(double %double) #0 {
define void @test_log_finite(double %double) #0 {
%logdouble = call double @llvm.log.f64(double %double)
store double %logdouble, double* @vardouble
- ; ANDROID-AARCH64-NOT: bl __log_finite
- ; CHECK: bl __log_finite
+ ; CHECK-NOT: bl __log_finite
+ ; CHECK: bl log
ret void
}
define void @test_log2_finite(double %double) #0 {
%log2double = call double @llvm.log2.f64(double %double)
store double %log2double, double* @vardouble
- ; ANDROID-AARCH64-NOT: bl __log2_finite
- ; CHECK: bl __log2_finite
+ ; CHECK-NOT: bl __log2_finite
+ ; CHECK: bl log2
ret void
}
define void @test_log10_finite(double %double) #0 {
%log10double = call double @llvm.log10.f64(double %double)
store double %log10double, double* @vardouble
- ; ANDROID-AARCH64-NOT: bl __log10_finite
- ; CHECK: bl __log10_finite
+ ; CHECK-NOT: bl __log10_finite
+ ; CHECK: bl log10
ret void
}
define void @test_pow_finite(double %double) #0 {
%powdouble = call double @llvm.pow.f64(double %double, double %double)
store double %powdouble, double* @vardouble
- ; ANDROID-AARCH64-NOT: bl __pow_finite
- ; CHECK: bl __pow_finite
+ ; CHECK-NOT: bl __pow_finite
+ ; CHECK: bl pow
ret void
}
diff --git a/llvm/test/CodeGen/X86/finite-libcalls.ll b/llvm/test/CodeGen/X86/finite-libcalls.ll
index d54ee48ea74d..31fadfb0aff8 100644
--- a/llvm/test/CodeGen/X86/finite-libcalls.ll
+++ b/llvm/test/CodeGen/X86/finite-libcalls.ll
@@ -9,7 +9,7 @@
define float @exp_f32(float %x) #0 {
; GNU-LABEL: exp_f32:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __expf_finite # TAILCALL
+; GNU-NEXT: jmp expf # TAILCALL
;
; WIN-LABEL: exp_f32:
; WIN: # %bb.0:
@@ -25,7 +25,7 @@ define float @exp_f32(float %x) #0 {
define double @exp_f64(double %x) #0 {
; GNU-LABEL: exp_f64:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __exp_finite # TAILCALL
+; GNU-NEXT: jmp exp # TAILCALL
;
; WIN-LABEL: exp_f64:
; WIN: # %bb.0:
@@ -44,7 +44,7 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 {
; GNU-NEXT: subq $24, %rsp
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __expl_finite
+; GNU-NEXT: callq expl
; GNU-NEXT: addq $24, %rsp
; GNU-NEXT: retq
;
@@ -80,7 +80,7 @@ define x86_fp80 @exp_f80(x86_fp80 %x) #0 {
define float @exp2_f32(float %x) #0 {
; GNU-LABEL: exp2_f32:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __exp2f_finite # TAILCALL
+; GNU-NEXT: jmp exp2f # TAILCALL
;
; WIN-LABEL: exp2_f32:
; WIN: # %bb.0:
@@ -96,7 +96,7 @@ define float @exp2_f32(float %x) #0 {
define double @exp2_f64(double %x) #0 {
; GNU-LABEL: exp2_f64:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __exp2_finite # TAILCALL
+; GNU-NEXT: jmp exp2 # TAILCALL
;
; WIN-LABEL: exp2_f64:
; WIN: # %bb.0:
@@ -115,7 +115,7 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 {
; GNU-NEXT: subq $24, %rsp
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __exp2l_finite
+; GNU-NEXT: callq exp2l
; GNU-NEXT: addq $24, %rsp
; GNU-NEXT: retq
;
@@ -151,7 +151,7 @@ define x86_fp80 @exp2_f80(x86_fp80 %x) #0 {
define float @log_f32(float %x) #0 {
; GNU-LABEL: log_f32:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __logf_finite # TAILCALL
+; GNU-NEXT: jmp logf # TAILCALL
;
; WIN-LABEL: log_f32:
; WIN: # %bb.0:
@@ -167,7 +167,7 @@ define float @log_f32(float %x) #0 {
define double @log_f64(double %x) #0 {
; GNU-LABEL: log_f64:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __log_finite # TAILCALL
+; GNU-NEXT: jmp log # TAILCALL
;
; WIN-LABEL: log_f64:
; WIN: # %bb.0:
@@ -186,7 +186,7 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 {
; GNU-NEXT: subq $24, %rsp
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __logl_finite
+; GNU-NEXT: callq logl
; GNU-NEXT: addq $24, %rsp
; GNU-NEXT: retq
;
@@ -222,7 +222,7 @@ define x86_fp80 @log_f80(x86_fp80 %x) #0 {
define float @log2_f32(float %x) #0 {
; GNU-LABEL: log2_f32:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __log2f_finite # TAILCALL
+; GNU-NEXT: jmp log2f # TAILCALL
;
; WIN-LABEL: log2_f32:
; WIN: # %bb.0:
@@ -238,7 +238,7 @@ define float @log2_f32(float %x) #0 {
define double @log2_f64(double %x) #0 {
; GNU-LABEL: log2_f64:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __log2_finite # TAILCALL
+; GNU-NEXT: jmp log2 # TAILCALL
;
; WIN-LABEL: log2_f64:
; WIN: # %bb.0:
@@ -257,7 +257,7 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 {
; GNU-NEXT: subq $24, %rsp
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __log2l_finite
+; GNU-NEXT: callq log2l
; GNU-NEXT: addq $24, %rsp
; GNU-NEXT: retq
;
@@ -293,7 +293,7 @@ define x86_fp80 @log2_f80(x86_fp80 %x) #0 {
define float @log10_f32(float %x) #0 {
; GNU-LABEL: log10_f32:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __log10f_finite # TAILCALL
+; GNU-NEXT: jmp log10f # TAILCALL
;
; WIN-LABEL: log10_f32:
; WIN: # %bb.0:
@@ -309,7 +309,7 @@ define float @log10_f32(float %x) #0 {
define double @log10_f64(double %x) #0 {
; GNU-LABEL: log10_f64:
; GNU: # %bb.0:
-; GNU-NEXT: jmp __log10_finite # TAILCALL
+; GNU-NEXT: jmp log10 # TAILCALL
;
; WIN-LABEL: log10_f64:
; WIN: # %bb.0:
@@ -328,7 +328,7 @@ define x86_fp80 @log10_f80(x86_fp80 %x) #0 {
; GNU-NEXT: subq $24, %rsp
; GNU-NEXT: fldt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __log10l_finite
+; GNU-NEXT: callq log10l
; GNU-NEXT: addq $24, %rsp
; GNU-NEXT: retq
;
@@ -365,7 +365,7 @@ define float @pow_f32(float %x) #0 {
; GNU-LABEL: pow_f32:
; GNU: # %bb.0:
; GNU-NEXT: movaps %xmm0, %xmm1
-; GNU-NEXT: jmp __powf_finite # TAILCALL
+; GNU-NEXT: jmp powf # TAILCALL
;
; WIN-LABEL: pow_f32:
; WIN: # %bb.0:
@@ -384,7 +384,7 @@ define double @pow_f64(double %x) #0 {
; GNU-LABEL: pow_f64:
; GNU: # %bb.0:
; GNU-NEXT: movaps %xmm0, %xmm1
-; GNU-NEXT: jmp __pow_finite # TAILCALL
+; GNU-NEXT: jmp pow # TAILCALL
;
; WIN-LABEL: pow_f64:
; WIN: # %bb.0:
@@ -407,7 +407,7 @@ define x86_fp80 @pow_f80(x86_fp80 %x) #0 {
; GNU-NEXT: fld %st(0)
; GNU-NEXT: fstpt {{[0-9]+}}(%rsp)
; GNU-NEXT: fstpt (%rsp)
-; GNU-NEXT: callq __powl_finite
+; GNU-NEXT: callq powl
; GNU-NEXT: addq $40, %rsp
; GNU-NEXT: retq
;
More information about the llvm-branch-commits
mailing list