[cfe-commits] r155498 - in /cfe/trunk: include/clang/Basic/Builtins.def test/Analysis/self-init.m test/CodeGen/libcalls.c

Chad Rosier mcrosier at apple.com
Tue Apr 24 15:40:01 PDT 2012


Author: mcrosier
Date: Tue Apr 24 17:40:01 2012
New Revision: 155498

URL: http://llvm.org/viewvc/llvm-project?rev=155498&view=rev
Log:
Add atan, atan2, exp, and log to the builtin math library functions.

With -fno-math-errno (the default for Darwin) or -ffast-math these library 
function can be marked readnone enabling more opportunities for CSE and other
optimizations.
rdar://11251464

Modified:
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/test/Analysis/self-init.m
    cfe/trunk/test/CodeGen/libcalls.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=155498&r1=155497&r2=155498&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 24 17:40:01 2012
@@ -804,14 +804,30 @@
 LIBBUILTIN(NSLogv, "vGa", "fP:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
 
 // Builtin math library functions
+LIBBUILTIN(atan, "dd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(atanl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(atanf, "ff", "fe", "math.h", ALL_LANGUAGES)
+
+LIBBUILTIN(atan2, "ddd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(atan2l, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(atan2f, "fff", "fe", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(cos, "dd", "fe", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(cosl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(cosf, "ff", "fe", "math.h", ALL_LANGUAGES)
 
+LIBBUILTIN(exp, "dd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(expl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(expf, "ff", "fe", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(fma, "dddd", "fc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fmal, "LdLdLdLd", "fc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fmaf, "ffff", "fc", "math.h", ALL_LANGUAGES)
 
+LIBBUILTIN(log, "dd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(logl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(logf, "ff", "fe", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(pow, "ddd", "fe", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(powl, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(powf, "fff", "fe", "math.h", ALL_LANGUAGES)

Modified: cfe/trunk/test/Analysis/self-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/self-init.m?rev=155498&r1=155497&r2=155498&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/self-init.m (original)
+++ cfe/trunk/test/Analysis/self-init.m Tue Apr 24 17:40:01 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify
 
 @class NSZone, NSCoder;
 @protocol NSObject- (id)self;

Modified: cfe/trunk/test/CodeGen/libcalls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls.c?rev=155498&r1=155497&r2=155498&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/libcalls.c (original)
+++ cfe/trunk/test/CodeGen/libcalls.c Tue Apr 24 17:40:01 2012
@@ -73,3 +73,48 @@
 // CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone
 // CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone
 // CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone
+
+// Just checking to make sure these library functions are marked readnone
+void test_builtins(double d, float f, long double ld) {
+// CHEC-NO: @test_builtins
+// CHEC-YES: @test_builtins
+  double atan_ = atan(d);
+  long double atanl_ = atanl(ld);
+  float atanf_ = atanf(f);
+// CHECK-NO: declare double @atan(double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @atanl(x86_fp80) nounwind readnone
+// CHECK-NO: declare float @atanf(float) nounwind readnone
+// CHECK-YES-NOT: declare double @atan(double) nounwind readnone
+// CHECK-YES-NOT: declare x86_fp80 @atanl(x86_fp80) nounwind readnone
+// CHECK-YES-NOT: declare float @atanf(float) nounwind readnone
+
+  double atan2_ = atan2(d, 2);
+  long double atan2l_ = atan2l(ld, ld);
+  float atan2f_ = atan2f(f, f);
+// CHECK-NO: declare double @atan2(double, double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone
+// CHECK-NO: declare float @atan2f(float, float) nounwind readnone
+// CHECK-YES-NOT: declare double @atan2(double, double) nounwind readnone
+// CHECK-YES-NOT: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone
+// CHECK-YES-NOT: declare float @atan2f(float, float) nounwind readnone
+
+  double exp_ = exp(d);
+  long double expl_ = expl(ld);
+  float expf_ = expf(f);
+// CHECK-NO: declare double @exp(double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @expl(x86_fp80) nounwind readnone
+// CHECK-NO: declare float @expf(float) nounwind readnone
+// CHECK-YES-NOT: declare double @exp(double) nounwind readnone
+// CHECK-YES-NOT: declare x86_fp80 @expl(x86_fp80) nounwind readnone
+// CHECK-YES-NOT: declare float @expf(float) nounwind readnone
+
+  double log_ = log(d);
+  long double logl_ = logl(ld);
+  float logf_ = logf(f);
+// CHECK-NO: declare double @log(double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @logl(x86_fp80) nounwind readnone
+// CHECK-NO: declare float @logf(float) nounwind readnone
+// CHECK-YES-NOT: declare double @log(double) nounwind readnone
+// CHECK-YES-NOT: declare x86_fp80 @logl(x86_fp80) nounwind readnone
+// CHECK-YES-NOT: declare float @logf(float) nounwind readnone
+}





More information about the cfe-commits mailing list