[PATCH] D42668: [Analysis] Disable calls to *_finite and other glibc-only functions on Android.

Chih-Hung Hsieh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 15:29:17 PST 2018


chh updated this revision to Diff 132064.
chh retitled this revision from "[Analysis] Disable log/log2/log10 finite lib calls on Android with -ffast-math." to "[Analysis] Disable calls to *_finite and other glibc-only functions on Android.".
chh edited the summary of this revision.

https://reviews.llvm.org/D42668

Files:
  lib/Analysis/TargetLibraryInfo.cpp
  test/CodeGen/AArch64/illegal-float-ops.ll


Index: test/CodeGen/AArch64/illegal-float-ops.ll
===================================================================
--- test/CodeGen/AArch64/illegal-float-ops.ll
+++ test/CodeGen/AArch64/illegal-float-ops.ll
@@ -265,6 +265,30 @@
   ret void
 }
 
+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
+  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
+  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
+  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
Index: lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- lib/Analysis/TargetLibraryInfo.cpp
+++ lib/Analysis/TargetLibraryInfo.cpp
@@ -397,24 +397,18 @@
     TLI.setUnavailable(LibFunc_flsll);
   }
 
-  // Android uses bionic instead of glibc. So disable some finite
-  // lib calls in glibc for Android. The list of unsupported lib
-  // calls for Android may expand as the need arises.
-  if (T.isAndroid()) {
-    TLI.setUnavailable(LibFunc_exp_finite);
-    TLI.setUnavailable(LibFunc_exp2_finite);
-    TLI.setUnavailable(LibFunc_pow_finite);
-  }
-
-  // The following functions are available on at least Linux:
-  if (!T.isOSLinux()) {
+  // The following functions are available on Linux,
+  // but Android uses bionic instead of glibc.
+  if (!T.isOSLinux() || T.isAndroid()) {
     TLI.setUnavailable(LibFunc_dunder_strdup);
     TLI.setUnavailable(LibFunc_dunder_strtok_r);
     TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
     TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
     TLI.setUnavailable(LibFunc_under_IO_getc);
     TLI.setUnavailable(LibFunc_under_IO_putc);
-    TLI.setUnavailable(LibFunc_memalign);
+    // Android has memalign.
+    if (!T.isOSLinux())
+      TLI.setUnavailable(LibFunc_memalign);
     TLI.setUnavailable(LibFunc_fopen64);
     TLI.setUnavailable(LibFunc_fseeko64);
     TLI.setUnavailable(LibFunc_fstat64);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42668.132064.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180130/9e30030d/attachment.bin>


More information about the llvm-commits mailing list