summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Gravelle <jgravelle@google.com>2017-02-21 22:37:27 +0000
committerJacob Gravelle <jgravelle@google.com>2017-02-21 22:37:27 +0000
commit40aefb5fe0252c4f8aedea385933c8db5a71441f (patch)
tree1306842ca839b7462a079f2843fdcbac9806f205
parent5e51f7d24e5330832453c2651838886598ddb47a (diff)
downloadbcm5719-llvm-40aefb5fe0252c4f8aedea385933c8db5a71441f.tar.gz
bcm5719-llvm-40aefb5fe0252c4f8aedea385933c8db5a71441f.zip
Declare lgamma library builtins as never being const
Summary: POSIX requires lgamma writes to an external global variable, signgam. This prevents annotating lgamma with readnone, which is incorrect on targets that write to signgam. Reviewers: efriedma, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29778 llvm-svn: 295781
-rw-r--r--clang/include/clang/Basic/Builtins.def8
-rw-r--r--clang/test/CodeGen/libcall-declarations.c15
2 files changed, 17 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index 08234c0051a..179b8265de3 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1087,9 +1087,11 @@ LIBBUILTIN(ilogb, "id", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+// POSIX math.h declares a global, signgam, that lgamma writes to, so these
+// shouldn't have "e" or "c" attributes
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)
diff --git a/clang/test/CodeGen/libcall-declarations.c b/clang/test/CodeGen/libcall-declarations.c
index 345b74fe97d..5a0b2ba0e63 100644
--- a/clang/test/CodeGen/libcall-declarations.c
+++ b/clang/test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@ void *use[] = {
// CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
// CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
// CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
// CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
// CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
// CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@ void *use[] = {
// CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
// CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
// CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
// CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
// CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
// CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@ void *use[] = {
// CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
// CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
// CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
OpenPOWER on IntegriCloud