Add the missing "n" to libm LIBBUILTIN definitions

The libm math functions should be marked with the "n" (nothrow) flag so that
the corresponding IR function declarations are tagged with the nounwind
attribute (this has been true in C mode, but not in C++ mode).

The test case has been updated to run in C++ mode in addition to in C mode.

llvm-svn: 190217
This commit is contained in:
Hal Finkel 2013-09-06 23:23:32 +00:00
parent d8c68b1852
commit 746b530a7d
2 changed files with 97 additions and 84 deletions

View File

@ -816,25 +816,25 @@ LIBBUILTIN(NSLog, "vG.", "fp:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
LIBBUILTIN(NSLogv, "vGa", "fP:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
// Builtin math library functions
LIBBUILTIN(acos, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(acosl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(acosf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(acos, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(acosl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(acosf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asin, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asinl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asinf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asin, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asinl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(asinf, "ff", "fne", "math.h", ALL_LANGUAGES)
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(atan, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atanl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atanf, "ff", "fne", "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(atan2, "ddd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atan2l, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(atan2f, "fff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceil, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceill, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceilf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceil, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceill, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(ceilf, "ff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(cimag, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
LIBBUILTIN(cimagf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
@ -844,85 +844,85 @@ LIBBUILTIN(creal, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
LIBBUILTIN(crealf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
LIBBUILTIN(creall, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
LIBBUILTIN(copysign, "ddd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysignl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysignf, "fff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysign, "ddd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysignl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(copysignf, "fff", "fnc", "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(cos, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(cosl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(cosf, "ff", "fne", "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(exp, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(expl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(expf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2l, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2f, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(exp2f, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabs, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabs, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fabsf, "ff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floor, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floor, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(floorf, "ff", "fnc", "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(fma, "dddd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmal, "LdLdLdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmaf, "ffff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmax, "ddd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmaxl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmaxf, "fff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmax, "ddd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmaxl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmaxf, "fff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmin, "ddd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fminl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fminf, "fff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fmin, "ddd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fminl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(fminf, "fff", "fnc", "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(log, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(logl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(logf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2l, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2f, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(log2f, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrint, "Lid", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrintl, "LiLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrintf, "Lif", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrint, "Lid", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrintl, "LiLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(lrintf, "Lif", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyint, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyint, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(nearbyintf, "ff", "fnc", "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)
LIBBUILTIN(pow, "ddd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(powl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(powf, "fff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rint, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(round, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(round, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(roundf, "ff", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sin, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sinl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sinf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sin, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sinl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sinf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrt, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrtl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrtf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrt, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrtl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(sqrtf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tan, "dd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tanl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tanf, "ff", "fe", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tan, "dd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tanl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(tanf, "ff", "fne", "math.h", ALL_LANGUAGES)
LIBBUILTIN(trunc, "dd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(truncl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(truncf, "ff", "fc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(trunc, "dd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(truncl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
LIBBUILTIN(truncf, "ff", "fnc", "math.h", ALL_LANGUAGES)
// Blocks runtime Builtin math library functions
LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h", ALL_LANGUAGES)

View File

@ -1,7 +1,12 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=CHECK-NOERRNO
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=CHECK-ERRNO
// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -S -o - -emit-llvm -x c++ %s | FileCheck %s -check-prefix=CHECK-NOERRNO
// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -o - -emit-llvm -x c++ -fmath-errno %s | FileCheck %s -check-prefix=CHECK-ERRNO
// Prototypes.
#ifdef __cplusplus
extern "C" {
#endif
double acos(double);
long double acosl(long double);
float acosf(float);
@ -77,17 +82,25 @@ float tanf(float);
double trunc(double);
long double truncl(long double);
float truncf(float);
#ifdef __cplusplus
}
#endif
// Force emission of the declare statements.
void *use[] = { acos, acosl, acosf, asin, asinl, asinf, atan, atanl, atanf,
atan2, atan2l, atan2f, ceil, ceill, ceilf, copysign, copysignl,
copysignf, cos, cosl, cosf, exp, expl, expf, exp2, exp2l, exp2f,
fabs, fabsl, fabsf, floor, floorl, floorf, fma, fmal, fmaf,
fmax, fmaxl, fmaxf, fmin, fminl, fminf, log, logl, logf, log2,
log2l, log2f, lrint, lrintl, lrintf, nearbyint, nearbyintl,
nearbyintf, pow, powl, powf, rint, rintl, rintf, round, roundl,
roundf, sin, sinl, sinf, sqrt, sqrtl, sqrtf, tan, tanl, tanf,
trunc, truncl, truncf };
#define F(x) ((void*)x)
void *use[] = { F(acos), F(acosl), F(acosf), F(asin), F(asinl), F(asinf),
F(atan), F(atanl), F(atanf), F(atan2), F(atan2l), F(atan2f),
F(ceil), F(ceill), F(ceilf), F(copysign), F(copysignl),
F(copysignf), F(cos), F(cosl), F(cosf), F(exp), F(expl),
F(expf), F(exp2), F(exp2l), F(exp2f), F(fabs), F(fabsl),
F(fabsf), F(floor), F(floorl), F(floorf), F(fma), F(fmal),
F(fmaf), F(fmax), F(fmaxl), F(fmaxf), F(fmin), F(fminl),
F(fminf), F(log), F(logl), F(logf), F(log2), F(log2l),
F(log2f), F(lrint), F(lrintl), F(lrintf), F(nearbyint),
F(nearbyintl), F(nearbyintf), F(pow), F(powl), F(powf),
F(rint), F(rintl), F(rintf), F(round), F(roundl), F(roundf),
F(sin), F(sinl), F(sinf), F(sqrt), F(sqrtl), F(sqrtf), F(tan),
F(tanl), F(tanf), F(trunc), F(truncl), F(truncf) };
// CHECK-NOERRNO: declare double @acos(double) [[NUW:#[0-9]+]]
// CHECK-NOERRNO: declare x86_fp80 @acosl(x86_fp80) [[NUW]]