Remove *_finite support, see rhbz#1803203

This commit is contained in:
serge-sans-paille 2020-02-28 14:47:58 +00:00
parent d323e42667
commit 38c19e024e
2 changed files with 400 additions and 1 deletions

View File

@ -0,0 +1,395 @@
From 6d15c4deab51498b70825fb6cefbbfe8f3d9bdcf Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@redhat.com>
Date: Fri, 21 Feb 2020 15:51:19 +0100
Subject: [PATCH] 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
---
llvm/lib/Analysis/TargetLibraryInfo.cpp | 3 +
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 73 +++----------------
.../test/CodeGen/AArch64/illegal-float-ops.ll | 24 +++---
llvm/test/CodeGen/X86/finite-libcalls.ll | 36 ++++-----
4 files changed, 45 insertions(+), 91 deletions(-)
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 2c4809b201e..3928fbd3447 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -472,6 +472,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 d1afc9a299a..f64d7fd8708 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3941,7 +3941,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: {
@@ -4050,68 +4049,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:
@@ -4181,16 +4140,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 ffa813e09c7..5f24cd4bf63 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 d54ee48ea74..31fadfb0aff 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
;
--
2.24.1

View File

@ -11,7 +11,7 @@
%global llvm_libdir %{_libdir}/%{name}
%global build_llvm_libdir %{buildroot}%{llvm_libdir}
%global rc_ver 2
%global baserelease 0.1
%global baserelease 0.2
%global llvm_srcdir llvm-%{version}%{?rc_ver:rc%{rc_ver}}.src
%global maj_ver 10
%global min_ver 0
@ -55,6 +55,7 @@ Source4: https://prereleases.llvm.org/%{version}/hans-gpg-key.asc
Patch0: 0001-CMake-Split-static-library-exports-into-their-own-ex.patch
Patch1: 0001-CMake-Split-test-binary-exports-into-their-own-expor.patch
Patch2: 0001-No-longer-generate-calls-to-_finite.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -480,6 +481,9 @@ fi
%endif
%changelog
* Fri Feb 28 2020 sguelton@redhat.com - 10.0.0-0.2.rc2
- Remove *_finite support, see rhbz#1803203
* Fri Feb 14 2020 sguelton@redhat.com - 10.0.0-0.1.rc2
- 10.0.0 rc2