diff options
Diffstat (limited to 'test/CodeGen/builtin-sqrt.c')
-rw-r--r-- | test/CodeGen/builtin-sqrt.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGen/builtin-sqrt.c b/test/CodeGen/builtin-sqrt.c new file mode 100644 index 0000000000..f93c5926d5 --- /dev/null +++ b/test/CodeGen/builtin-sqrt.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fmath-errno -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=HAS_ERRNO +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=NO_ERRNO + +// FIXME: If a builtin is supposed to have identical semantics to its libm twin, then it +// should not be marked "constant" in Builtins.def because that means it can't set errno. +// Note that both runs have 'readnone' on the libcall here. + +float foo(float X) { + // HAS_ERRNO: call float @sqrtf(float + // NO_ERRNO: call float @sqrtf(float + return __builtin_sqrtf(X); +} + +// HAS_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]] +// HAS_ERRNO: attributes [[ATTR]] = { nounwind readnone {{.*}}} + +// NO_ERRNO: declare float @sqrtf(float) [[ATTR:#[0-9]+]] +// NO_ERRNO: attributes [[ATTR]] = { nounwind readnone {{.*}}} + |