Revert "[PATCH] [TargetLibraryInfo] Update run time support for Windows"

This reverts accidental commit ff5527718d.

llvm-svn: 353118
This commit is contained in:
Evandro Menezes 2019-02-04 23:34:50 +00:00
parent d016763774
commit 98f356cd74
5 changed files with 159 additions and 141 deletions

View File

@ -160,20 +160,95 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
}
if (T.isOSWindows() && !T.isOSCygMing()) {
bool is64 = (T.getArch() == Triple::aarch64 ||
T.getArch() == Triple::x86_64);
// Win32 does not support long double
TLI.setUnavailable(LibFunc_acosl);
TLI.setUnavailable(LibFunc_asinl);
TLI.setUnavailable(LibFunc_atanl);
TLI.setUnavailable(LibFunc_atan2l);
TLI.setUnavailable(LibFunc_ceill);
TLI.setUnavailable(LibFunc_copysignl);
TLI.setUnavailable(LibFunc_cosl);
TLI.setUnavailable(LibFunc_coshl);
TLI.setUnavailable(LibFunc_expl);
TLI.setUnavailable(LibFunc_fabsf); // Win32 and Win64 both lack fabsf
TLI.setUnavailable(LibFunc_fabsl);
TLI.setUnavailable(LibFunc_floorl);
TLI.setUnavailable(LibFunc_fmaxl);
TLI.setUnavailable(LibFunc_fminl);
TLI.setUnavailable(LibFunc_fmodl);
TLI.setUnavailable(LibFunc_frexpl);
TLI.setUnavailable(LibFunc_ldexpf);
TLI.setUnavailable(LibFunc_ldexpl);
TLI.setUnavailable(LibFunc_logl);
TLI.setUnavailable(LibFunc_modfl);
TLI.setUnavailable(LibFunc_powl);
TLI.setUnavailable(LibFunc_sinl);
TLI.setUnavailable(LibFunc_sinhl);
TLI.setUnavailable(LibFunc_sqrtl);
TLI.setUnavailable(LibFunc_tanl);
TLI.setUnavailable(LibFunc_tanhl);
// Win32 does not support float math functions, in general.
if (!is64) {
// Win32 only has C89 math
TLI.setUnavailable(LibFunc_acosh);
TLI.setUnavailable(LibFunc_acoshf);
TLI.setUnavailable(LibFunc_acoshl);
TLI.setUnavailable(LibFunc_asinh);
TLI.setUnavailable(LibFunc_asinhf);
TLI.setUnavailable(LibFunc_asinhl);
TLI.setUnavailable(LibFunc_atanh);
TLI.setUnavailable(LibFunc_atanhf);
TLI.setUnavailable(LibFunc_atanhl);
TLI.setUnavailable(LibFunc_cabs);
TLI.setUnavailable(LibFunc_cabsf);
TLI.setUnavailable(LibFunc_cabsl);
TLI.setUnavailable(LibFunc_cbrt);
TLI.setUnavailable(LibFunc_cbrtf);
TLI.setUnavailable(LibFunc_cbrtl);
TLI.setUnavailable(LibFunc_exp2);
TLI.setUnavailable(LibFunc_exp2f);
TLI.setUnavailable(LibFunc_exp2l);
TLI.setUnavailable(LibFunc_expm1);
TLI.setUnavailable(LibFunc_expm1f);
TLI.setUnavailable(LibFunc_expm1l);
TLI.setUnavailable(LibFunc_log2);
TLI.setUnavailable(LibFunc_log2f);
TLI.setUnavailable(LibFunc_log2l);
TLI.setUnavailable(LibFunc_log1p);
TLI.setUnavailable(LibFunc_log1pf);
TLI.setUnavailable(LibFunc_log1pl);
TLI.setUnavailable(LibFunc_logb);
TLI.setUnavailable(LibFunc_logbf);
TLI.setUnavailable(LibFunc_logbl);
TLI.setUnavailable(LibFunc_nearbyint);
TLI.setUnavailable(LibFunc_nearbyintf);
TLI.setUnavailable(LibFunc_nearbyintl);
TLI.setUnavailable(LibFunc_rint);
TLI.setUnavailable(LibFunc_rintf);
TLI.setUnavailable(LibFunc_rintl);
TLI.setUnavailable(LibFunc_round);
TLI.setUnavailable(LibFunc_roundf);
TLI.setUnavailable(LibFunc_roundl);
TLI.setUnavailable(LibFunc_trunc);
TLI.setUnavailable(LibFunc_truncf);
TLI.setUnavailable(LibFunc_truncl);
// Win32 provides some C99 math with mangled names
TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
if (T.getArch() == Triple::x86) {
// Win32 on x86 implements single-precision math functions as macros
TLI.setUnavailable(LibFunc_acosf);
TLI.setUnavailable(LibFunc_asinf);
TLI.setUnavailable(LibFunc_atanf);
TLI.setUnavailable(LibFunc_atan2f);
TLI.setUnavailable(LibFunc_ceilf);
TLI.setUnavailable(LibFunc_copysignf);
TLI.setUnavailable(LibFunc_cosf);
TLI.setUnavailable(LibFunc_coshf);
TLI.setUnavailable(LibFunc_expf);
TLI.setUnavailable(LibFunc_floorf);
TLI.setUnavailable(LibFunc_fminf);
TLI.setUnavailable(LibFunc_fmaxf);
TLI.setUnavailable(LibFunc_fmodf);
TLI.setUnavailable(LibFunc_logf);
TLI.setUnavailable(LibFunc_log10f);
@ -185,95 +260,8 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_tanf);
TLI.setUnavailable(LibFunc_tanhf);
}
TLI.setUnavailable(LibFunc_copysignf);
TLI.setUnavailable(LibFunc_fabsf);
TLI.setUnavailable(LibFunc_fmaxf);
TLI.setUnavailable(LibFunc_fminf);
TLI.setUnavailable(LibFunc_frexpf);
TLI.setUnavailable(LibFunc_ldexpf);
// Win32 does not support long double.
TLI.setUnavailable(LibFunc_acosl);
TLI.setUnavailable(LibFunc_asinl);
TLI.setUnavailable(LibFunc_atanl);
TLI.setUnavailable(LibFunc_atan2l);
TLI.setUnavailable(LibFunc_ceill);
TLI.setUnavailable(LibFunc_copysignl);
TLI.setUnavailable(LibFunc_cosl);
TLI.setUnavailable(LibFunc_coshl);
TLI.setUnavailable(LibFunc_expl);
TLI.setUnavailable(LibFunc_fabsl);
TLI.setUnavailable(LibFunc_floorl);
TLI.setUnavailable(LibFunc_fmaxl);
TLI.setUnavailable(LibFunc_fminl);
TLI.setUnavailable(LibFunc_fmodl);
TLI.setUnavailable(LibFunc_frexpl);
TLI.setUnavailable(LibFunc_ldexpl);
TLI.setUnavailable(LibFunc_logl);
TLI.setUnavailable(LibFunc_log10l);
TLI.setUnavailable(LibFunc_modfl);
TLI.setUnavailable(LibFunc_powl);
TLI.setUnavailable(LibFunc_sinl);
TLI.setUnavailable(LibFunc_sinhl);
TLI.setUnavailable(LibFunc_sqrtl);
TLI.setUnavailable(LibFunc_tanl);
TLI.setUnavailable(LibFunc_tanhl);
// Win32 does not support C89 math functions, in general.
// acosh
TLI.setUnavailable(LibFunc_acoshf);
TLI.setUnavailable(LibFunc_acoshl);
// asinh
TLI.setUnavailable(LibFunc_asinhf);
TLI.setUnavailable(LibFunc_asinhl);
// atanh
TLI.setUnavailable(LibFunc_atanhf);
TLI.setUnavailable(LibFunc_atanhl);
TLI.setUnavailable(LibFunc_cabs);
TLI.setUnavailable(LibFunc_cabsf);
TLI.setUnavailable(LibFunc_cabsl);
// cbrt
TLI.setUnavailable(LibFunc_cbrtf);
TLI.setUnavailable(LibFunc_cbrtl);
// exp2
TLI.setUnavailable(LibFunc_exp2f);
TLI.setUnavailable(LibFunc_exp2l);
// expm1
TLI.setUnavailable(LibFunc_expm1f);
TLI.setUnavailable(LibFunc_expm1l);
// log1p
TLI.setUnavailable(LibFunc_log1pf);
TLI.setUnavailable(LibFunc_log1pl);
// log2
TLI.setUnavailable(LibFunc_log2f);
TLI.setUnavailable(LibFunc_log2l);
// logb
if (!is64)
TLI.setUnavailable(LibFunc_logbf);
TLI.setUnavailable(LibFunc_logbl);
// nearbyint
TLI.setUnavailable(LibFunc_nearbyintf);
TLI.setUnavailable(LibFunc_nearbyintl);
// rint
TLI.setUnavailable(LibFunc_rintf);
TLI.setUnavailable(LibFunc_rintl);
// round
TLI.setUnavailable(LibFunc_roundf);
TLI.setUnavailable(LibFunc_roundl);
// trunc
TLI.setUnavailable(LibFunc_truncf);
TLI.setUnavailable(LibFunc_truncl);
// Win32 supports some C89 and C99 math functions, but with mangled names.
TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
if (is64)
TLI.setAvailableWithName(LibFunc_logbf, "_logbf");
// Win32 does not support these C99 functions.
TLI.setUnavailable(LibFunc_atoll);
TLI.setUnavailable(LibFunc_llabs);
// Win32 does not support these functions, but they are
// Win32 does *not* provide these functions, but they are
// generally available on POSIX-compliant systems:
TLI.setUnavailable(LibFunc_access);
TLI.setUnavailable(LibFunc_bcmp);
@ -329,6 +317,12 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_utime);
TLI.setUnavailable(LibFunc_utimes);
TLI.setUnavailable(LibFunc_write);
// Win32 does *not* provide provide these functions, but they are
// specified by C99:
TLI.setUnavailable(LibFunc_atoll);
TLI.setUnavailable(LibFunc_frexpf);
TLI.setUnavailable(LibFunc_llabs);
}
switch (T.getOS()) {

View File

@ -335,9 +335,9 @@ define double @log2_test2(float %f) {
define float @logb_test1(float %f) {
; CHECK-LABEL: @logb_test1(
; LIN64-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]])
; LIN64-NEXT: ret float [[LOGBF]]
; WIN32: [[LOGBF:%.*]] = call fast double @logb(double [[F:%.*]])
; LINUX-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]])
; LINUX-NEXT: ret float [[LOGBF]]
; WIN96: [[LOGBF:%.*]] = call fast double @logb(double [[F:%.*]])
;
%conv = fpext float %f to double
%call = call fast double @logb(double %conv)
@ -498,9 +498,9 @@ define double @tanh_test2(float %f) {
; flags are propagated for shrunken *binary* double FP calls.
define float @max1(float %a, float %b) {
; CHECK-LABEL: @max1(
; LINUX-NEXT: [[FMAXF:%.*]] = call arcp float @fmaxf(float [[A:%.*]], float [[B:%.*]])
; LINUX-NEXT: ret float [[FMAXF]]
; WIN96: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]])
; LIN64-NEXT: [[FMAXF:%.*]] = call arcp float @fmaxf(float [[A:%.*]], float [[B:%.*]])
; LIN64-NEXT: ret float [[FMAXF]]
; WIN32: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]])
;
%c = fpext float %a to double
%d = fpext float %b to double

View File

@ -1,10 +1,10 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck %s
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck --check-prefixes=CHECK,DONT-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck --check-prefixes=CHECK,C89-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" -enable-debugify 2>&1 | FileCheck --check-prefix=DBG-VALID %s
declare double @floor(double)
@ -61,8 +61,19 @@ define float @test_shrink_libcall_ceil(float %C) {
define float @test_shrink_libcall_round(float %C) {
; CHECK-LABEL: @test_shrink_libcall_round(
; CHECK-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]])
; CHECK-NEXT: ret float [[F]]
; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]])
; DO-SIMPLIFY-NEXT: ret float [[F]]
;
; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]])
; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; DONT-SIMPLIFY-NEXT: ret float [[F]]
;
; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]])
; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; C89-SIMPLIFY-NEXT: ret float [[F]]
;
%D = fpext float %C to double
; --> roundf
@ -73,8 +84,19 @@ define float @test_shrink_libcall_round(float %C) {
define float @test_shrink_libcall_nearbyint(float %C) {
; CHECK-LABEL: @test_shrink_libcall_nearbyint(
; CHECK-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]])
; CHECK-NEXT: ret float [[F]]
; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]])
; DO-SIMPLIFY-NEXT: ret float [[F]]
;
; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]])
; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; DONT-SIMPLIFY-NEXT: ret float [[F]]
;
; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]])
; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; C89-SIMPLIFY-NEXT: ret float [[F]]
;
%D = fpext float %C to double
; --> nearbyintf
@ -85,8 +107,19 @@ define float @test_shrink_libcall_nearbyint(float %C) {
define float @test_shrink_libcall_trunc(float %C) {
; CHECK-LABEL: @test_shrink_libcall_trunc(
; CHECK-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]])
; CHECK-NEXT: ret float [[F]]
; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]])
; DO-SIMPLIFY-NEXT: ret float [[F]]
;
; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]])
; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; DONT-SIMPLIFY-NEXT: ret float [[F]]
;
; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double
; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]])
; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float
; C89-SIMPLIFY-NEXT: ret float [[F]]
;
%D = fpext float %C to double
; --> truncf

View File

@ -73,9 +73,11 @@ define float @test_simplify3(float %x) {
define double @test_simplify3n(double %x) {
; CHECK-LABEL: @test_simplify3n(
; CHECK-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00
; CHECK-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) [[NUW_RO:#[0-9]+]]
; CHECK-NEXT: ret double [[EXP2]]
; ANY-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00
; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) [[NUW_RO]]
; ANY-NEXT: ret double [[EXP2]]
; WIN-NEXT: [[POW:%.*]] = call double @pow(double 2.500000e-01, double [[X:%.*]])
; WIN-NEXT: ret double [[POW]]
;
%retval = call double @pow(double 0.25, double %x)
ret double %retval
@ -106,8 +108,10 @@ define <2 x double> @test_simplify3vn(<2 x double> %x) {
define double @test_simplify4(double %x) {
; CHECK-LABEL: @test_simplify4(
; CHECK-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) [[NUW_RO]]
; CHECK-NEXT: ret double [[EXP2]]
; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) [[NUW_RO]]
; ANY-NEXT: ret double [[EXP2]]
; WIN-NEXT: [[POW:%.*]] = call double @pow(double 2.000000e+00, double [[X:%.*]])
; WIN-NEXT: ret double [[POW]]
;
%retval = call double @pow(double 2.0, double %x)
ret double %retval
@ -191,7 +195,7 @@ define <2 x double> @test_simplify6v(<2 x double> %x) {
define float @test_simplify7(float %x) {
; CHECK-LABEL: @test_simplify7(
; ANY-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO]]
; WIN-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO]]
; WIN-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO:#[0-9]+]]
; CHECK-NEXT: [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]])
; CHECK-NEXT: [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]]

View File

@ -1,11 +1,11 @@
; RUN: opt < %s -O2 -S -mtriple=i386-pc-win32 | FileCheck %s --check-prefixes=CHECK,WIN32
; RUN: opt < %s -O2 -S -mtriple=x86_64-pc-win32 | FileCheck %s --check-prefixes=CHECK,WIN64
; RUN: opt < %s -O2 -S -mtriple=i386-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW32
; RUN: opt < %s -O2 -S -mtriple=x86_64-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW64
; RUN: opt -O2 -S -mtriple=i386-pc-win32 < %s | FileCheck %s --check-prefixes=CHECK,WIN32
; RUN: opt -O2 -S -mtriple=x86_64-pc-win32 < %s | FileCheck %s --check-prefixes=CHECK,WIN64
; RUN: opt -O2 -S -mtriple=i386-pc-mingw32 < %s | FileCheck %s --check-prefixes=CHECK,MINGW32
; RUN: opt -O2 -S -mtriple=x86_64-pc-mingw32 < %s | FileCheck %s --check-prefixes=CHECK,MINGW64
; x86 win32 msvcrt does not provide entry points for single-precision libm.
; x86-64 win32 msvcrt does, but with exceptions
; msvcrt does not provide all of C99 math, but mingw32 does.
; x86-64 win32 msvcrt does (except for fabsf)
; msvcrt does not provide C99 math, but mingw32 does.
declare double @acos(double %x)
define float @float_acos(float %x) nounwind readnone {
@ -188,19 +188,6 @@ define float @float_log(float %x) nounwind readnone {
ret float %3
}
declare double @logb(double %x)
define float @float_logb(float %x) nounwind readnone {
; CHECK-LABEL: @float_logb(
; WIN32-NOT: float @logbf
; WIN32: double @logb
; WIN64-NOT: float @logbf
; WIN64: double @logb
%1 = fpext float %x to double
%2 = call double @logb(double %1)
%3 = fptrunc double %2 to float
ret float %3
}
declare double @pow(double %x, double %y)
define float @float_pow(float %x, float %y) nounwind readnone {
; CHECK-LABEL: @float_pow(
@ -284,14 +271,14 @@ define float @float_tanh(float %x) nounwind readnone {
ret float %3
}
; win32 does not have roundf; mingw32 does
; win32 does not have round; mingw32 does
declare double @round(double %x)
define float @float_round(float %x) nounwind readnone {
; CHECK-LABEL: @float_round(
; WIN32-NOT: double @round
; WIN32: float @llvm.round.f32
; WIN64-NOT: double @round
; WIN64: float @llvm.round.f32
; WIN32-NOT: float @roundf
; WIN32: double @round
; WIN64-NOT: float @roundf
; WIN64: double @round
; MINGW32-NOT: double @round
; MINGW32: float @llvm.round.f32
; MINGW64-NOT: double @round
@ -304,7 +291,7 @@ define float @float_round(float %x) nounwind readnone {
declare float @powf(float, float)
; win32 lacks sqrtf & fabsf, win64 lacks fabsf, but
; win32 lacks sqrtf&fabsf, win64 lacks fabsf, but
; calls to the intrinsics can be emitted instead.
define float @float_powsqrt(float %x) nounwind readnone {
; CHECK-LABEL: @float_powsqrt(