summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2018-11-06 18:23:32 +0000
committerEli Friedman <efriedma@codeaurora.org>2018-11-06 18:23:32 +0000
commite3a5fc6d80ce33a22e62e731996e75e485c53480 (patch)
treec7be0f201069407c6d136527c276f36ed9c06595
parent786760a9f6e6f92088aeafae5f06de092e9fc4df (diff)
downloadbcm5719-llvm-e3a5fc6d80ce33a22e62e731996e75e485c53480.tar.gz
bcm5719-llvm-e3a5fc6d80ce33a22e62e731996e75e485c53480.zip
Disable calls to *_finite and other glibc-only functions on Musl.
Non-GNU environments don't have __finite_*, so treat them as unavailable. Differential Revision: https://reviews.llvm.org/D51282 llvm-svn: 346250
-rw-r--r--llvm/lib/Analysis/TargetLibraryInfo.cpp10
-rw-r--r--llvm/test/Transforms/ConstProp/calls-math-finite.ll43
-rw-r--r--llvm/test/Transforms/InferFunctionAttrs/annotate.ll2
3 files changed, 49 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index fb678febe23..b3cd40e098e 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -413,17 +413,17 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_flsll);
}
- // The following functions are available on Linux,
- // but Android uses bionic instead of glibc.
- if (!T.isOSLinux() || T.isAndroid()) {
+ // The following functions are only available on GNU/Linux (using glibc).
+ // Linux variants without glibc (eg: bionic, musl) may have some subset.
+ if (!T.isOSLinux() || !T.isGNUEnvironment()) {
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);
- // But, Android has memalign.
- if (!T.isAndroid())
+ // But, Android and musl have memalign.
+ if (!T.isAndroid() && !T.isMusl())
TLI.setUnavailable(LibFunc_memalign);
TLI.setUnavailable(LibFunc_fopen64);
TLI.setUnavailable(LibFunc_fseeko64);
diff --git a/llvm/test/Transforms/ConstProp/calls-math-finite.ll b/llvm/test/Transforms/ConstProp/calls-math-finite.ll
index 93741612fc5..d13b798bde2 100644
--- a/llvm/test/Transforms/ConstProp/calls-math-finite.ll
+++ b/llvm/test/Transforms/ConstProp/calls-math-finite.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -constprop -S | FileCheck %s
+; RUN: opt < %s -constprop -S -mtriple=unknown-unknown-linux-musl | FileCheck -check-prefix=MUSL %s
; Test to verify constant folding can occur when math routines are mapped
; to the __<func>_finite versions of functions due to __FINITE_MATH_ONLY__
@@ -57,6 +58,48 @@ define void @T() {
; CHECK-NEXT: store float 0x40240926E0000000, float* [[SLOTF]]
; CHECK-NEXT: ret void
;
+; MUSL-LABEL: @T(
+; MUSL-NEXT: [[SLOT:%.*]] = alloca double
+; MUSL-NEXT: [[SLOTF:%.*]] = alloca float
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+; MUSL-NEXT: call
+; MUSL-NEXT: store
+
%slot = alloca double
%slotf = alloca float
diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
index 37dfe41cfcb..161873be56e 100644
--- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
+++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
@@ -1,7 +1,7 @@
; RUN: opt < %s -mtriple=x86_64-- -inferattrs -S | FileCheck %s
; RUN: opt < %s -mtriple=x86_64-- -passes=inferattrs -S | FileCheck %s
; RUN: opt < %s -mtriple=x86_64-apple-macosx10.8.0 -inferattrs -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-DARWIN %s
-; RUN: opt < %s -mtriple=x86_64-unknown-linux -inferattrs -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LINUX %s
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -inferattrs -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LINUX %s
; RUN: opt < %s -mtriple=nvptx -inferattrs -S | FileCheck -check-prefix=CHECK-NVPTX %s
; operator new routines
OpenPOWER on IntegriCloud