[llvm] r323898 - [Analysis] Disable calls to *_finite and other glibc-only functions on Android.

Chih-Hung Hsieh via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 31 11:12:50 PST 2018


Author: chh
Date: Wed Jan 31 11:12:50 2018
New Revision: 323898

URL: http://llvm.org/viewvc/llvm-project?rev=323898&view=rev
Log:
[Analysis] Disable calls to *_finite and other glibc-only functions on Android.

Since r322087, glibc's finite lib calls are generated when possible.
However, they are not supported on Android. This change also
disables other functions not available on Android.

Differential Revision: http://reviews.llvm.org/D42668

Modified:
    llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
    llvm/trunk/test/CodeGen/AArch64/illegal-float-ops.ll

Modified: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=323898&r1=323897&r2=323898&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp Wed Jan 31 11:12:50 2018
@@ -397,24 +397,18 @@ static void initialize(TargetLibraryInfo
     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);
+    // But, Android has memalign.
+    if (!T.isAndroid())
+      TLI.setUnavailable(LibFunc_memalign);
     TLI.setUnavailable(LibFunc_fopen64);
     TLI.setUnavailable(LibFunc_fseeko64);
     TLI.setUnavailable(LibFunc_fstat64);

Modified: llvm/trunk/test/CodeGen/AArch64/illegal-float-ops.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/illegal-float-ops.ll?rev=323898&r1=323897&r2=323898&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/illegal-float-ops.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/illegal-float-ops.ll Wed Jan 31 11:12:50 2018
@@ -265,6 +265,30 @@ define void @test_exp2_finite(double %do
   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




More information about the llvm-commits mailing list