[llvm] r198093 - Disable transforms that introduce calls to exp10*() on Linux due to

Chandler Carruth chandlerc at gmail.com
Fri Dec 27 18:40:19 PST 2013


Author: chandlerc
Date: Fri Dec 27 20:40:19 2013
New Revision: 198093

URL: http://llvm.org/viewvc/llvm-project?rev=198093&view=rev
Log:
Disable transforms that introduce calls to exp10*() on Linux due to
widespread glibc bugs.

The glibc implementation of exp10 has a very serious precision bug in
version 2.15 (and older versions). This is still very widely used (the
current Ubuntu LTS for example uses it) and so it isn't reasonable to
make transforms that produce these functions. This fixes many
miscompiles introduced when we started transforming pow(10.0, ...) into
exp10, and it may have fixed other latent miscompiles where exp10
provided sufficient precision but exp10f did not.

This is all really horrible. The primary bug has been fixed for over
a year and glibc 2.18 works correctly for the test cases I have, but it
will be 2017 before the LTS using 2.15 is no longer supported by Ubuntu
(and thus reasonable for folks to be relying on). =[ We're either going
to need to live without these optimizations, or find a way to switch
behavior more dynamically than using simply the fact that the OS is
"Linux".

To make matters worse, there appears to be significant testing and
fixing of numerous other bugs in the exp10 family of functions right now
in glibc. While those haven't been causing problems I've seen in the
wild, it gives me concerns that we may need to wait until an even later
release of glibc before we can reliably transform code into exp10.

Modified:
    llvm/trunk/lib/Target/TargetLibraryInfo.cpp
    llvm/trunk/test/Transforms/InstCombine/double-float-shrink-1.ll

Modified: llvm/trunk/lib/Target/TargetLibraryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLibraryInfo.cpp?rev=198093&r1=198092&r2=198093&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLibraryInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetLibraryInfo.cpp Fri Dec 27 20:40:19 2013
@@ -574,14 +574,11 @@ static void initialize(TargetLibraryInfo
     TLI.setUnavailable(LibFunc::llabs);
   }
 
-  // exp10, exp10f, exp10l is available on at least Linux (GLIBC)
-  // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
-  // and their names are __exp10 and __exp10f. exp10l is not available on
-  // OS X or iOS.
   switch (T.getOS()) {
-  case Triple::Linux:
-    break;
   case Triple::MacOSX:
+    // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
+    // and their names are __exp10 and __exp10f. exp10l is not available on
+    // OS X or iOS.
     TLI.setUnavailable(LibFunc::exp10l);
     if (T.isMacOSXVersionLT(10, 9)) {
       TLI.setUnavailable(LibFunc::exp10);
@@ -601,6 +598,13 @@ static void initialize(TargetLibraryInfo
       TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f");
     }
     break;
+  case Triple::Linux:
+    // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
+    // buggy prior to glibc version 2.18. Until this version is widely deployed
+    // or we have a reasonable detection strategy, we cannot use exp10 reliably
+    // on Linux.
+    //
+    // Fall through to disable all of them.
   default:
     TLI.setUnavailable(LibFunc::exp10);
     TLI.setUnavailable(LibFunc::exp10f);

Modified: llvm/trunk/test/Transforms/InstCombine/double-float-shrink-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/double-float-shrink-1.ll?rev=198093&r1=198092&r2=198093&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/double-float-shrink-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/double-float-shrink-1.ll Fri Dec 27 20:40:19 2013
@@ -157,7 +157,10 @@ define float @exp10_test(float %f) nounw
    %call = call double @exp10(double %conv)
    %conv1 = fptrunc double %call to float
    ret float %conv1
-; CHECK: call float @exp10f(float %f)
+; FIXME: Re-enable this when Linux allows transforming this again, or when we
+; can use builtin attributes to test the transform regardless of OS.
+; DISABLED-CHECK: call float @exp10f(float %f)
+; CHECK: call double @exp10(double %conv)
 }
 
 define double @exp10_test2(float %f) nounwind readnone {





More information about the llvm-commits mailing list