[llvm] 80c0e8d - [x86][Windows] Fix chromium build break (#101268)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 17:47:26 PDT 2024


Author: Farzon Lotfi
Date: 2024-07-30T20:47:23-04:00
New Revision: 80c0e8d572d3b1c34d66faffc42bcfc9432583ec

URL: https://github.com/llvm/llvm-project/commit/80c0e8d572d3b1c34d66faffc42bcfc9432583ec
DIFF: https://github.com/llvm/llvm-project/commit/80c0e8d572d3b1c34d66faffc42bcfc9432583ec.diff

LOG: [x86][Windows] Fix chromium build break (#101268)

Windows does not support float C89 math functions like:
- acosf
- asinf
- atanf
- coshf
- sinhf
- tanhf 
All 6 are disabled in
[TargetLibraryInfo.cpp:293](https://github.com/llvm/llvm-project/blob/39e192b379362e9e645427631c35450d55ed517d/llvm/lib/Analysis/TargetLibraryInfo.cpp#L293C4-L296C41)
These 6 libfuncs need to be type promoted.

This PR fixes the bug introduced by
https://github.com/llvm/llvm-project/pull/98949

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index b971afda4229a..73405397aa6e8 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2475,8 +2475,12 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
       (Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()))
     // clang-format off
    for (ISD::NodeType Op :
-         {ISD::FCEIL,  ISD::STRICT_FCEIL,
+         {ISD::FACOS,  ISD::STRICT_FACOS,
+          ISD::FASIN,  ISD::STRICT_FASIN,
+          ISD::FATAN,  ISD::STRICT_FATAN,
+          ISD::FCEIL,  ISD::STRICT_FCEIL,
           ISD::FCOS,   ISD::STRICT_FCOS,
+          ISD::FCOSH,  ISD::STRICT_FCOSH,
           ISD::FEXP,   ISD::STRICT_FEXP,
           ISD::FFLOOR, ISD::STRICT_FFLOOR,
           ISD::FREM,   ISD::STRICT_FREM,
@@ -2484,7 +2488,9 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
           ISD::FLOG10, ISD::STRICT_FLOG10,
           ISD::FPOW,   ISD::STRICT_FPOW,
           ISD::FSIN,   ISD::STRICT_FSIN,
-          ISD::FTAN,   ISD::STRICT_FTAN})
+          ISD::FSINH,  ISD::STRICT_FSINH,
+          ISD::FTAN,   ISD::STRICT_FTAN,
+          ISD::FTANH,  ISD::STRICT_FTANH})
       if (isOperationExpand(Op, MVT::f32))
         setOperationAction(Op, MVT::f32, Promote);
   // clang-format on

diff  --git a/llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll b/llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll
index 835cd9f509b0d..5d4e86afc8ace 100644
--- a/llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll
+++ b/llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll
@@ -180,12 +180,15 @@ define float @tan(float %x) #0 {
 define float @acos(float %x) #0 {
 ; CHECK-LABEL: acos:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    fstpl (%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    calll _acos
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _acosf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.acos.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result
@@ -194,12 +197,15 @@ define float @acos(float %x) #0 {
 define float @asin(float %x) #0 {
 ; CHECK-LABEL: asin:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    fstpl (%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    calll _asin
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _asinf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.asin.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result
@@ -208,12 +214,15 @@ define float @asin(float %x) #0 {
 define float @atan(float %x) #0 {
 ; CHECK-LABEL: atan:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
+; CHECK-NEXT:    fstpl (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _atanf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    calll _atan
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.atan.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result
@@ -222,12 +231,15 @@ define float @atan(float %x) #0 {
 define float @cosh(float %x) #0 {
 ; CHECK-LABEL: cosh:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    fstpl (%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    calll _cosh
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _coshf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.cosh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result
@@ -236,26 +248,31 @@ define float @cosh(float %x) #0 {
 define float @sinh(float %x) #0 {
 ; CHECK-LABEL: sinh:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    fstpl (%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    calll _sinh
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _sinhf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.sinh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result
 }
 
 define float @tanh(float %x) #0 {
-; CHECK-LABEL: tanh:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    pushl   %eax
+; CHECK-NEXT:    subl $12, %esp
 ; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
-; CHECK-NEXT:    fstps (%esp)
+; CHECK-NEXT:    fstpl (%esp)
 ; CHECK-NEXT:    wait
-; CHECK-NEXT:    calll _tanhf
-; CHECK-NEXT:    popl    %eax
+; CHECK-NEXT:    calll _tanh
+; CHECK-NEXT:    fstps {{[0-9]+}}(%esp)
+; CHECK-NEXT:    flds {{[0-9]+}}(%esp)
+; CHECK-NEXT:    wait
+; CHECK-NEXT:    addl $12, %esp
 ; CHECK-NEXT:    retl
   %result = call float @llvm.experimental.constrained.tanh.f32(float %x, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
   ret float %result


        


More information about the llvm-commits mailing list