diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-09-08 21:18:03 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-09-08 21:18:03 +0000 |
commit | 87198c304cc1fae48b7a06ce9faf8b4017981059 (patch) | |
tree | 1042c6653104112b368d5e4b1a2d7ff11319f505 | |
parent | af37061fea31f3f1d0638edb5486e8d72c701522 (diff) |
The frexp, modf, and remquo builtins are not 'const'.
These functions return a second value by writing to a pointer argument,
so they cannot be marked 'readnone' which implies that they don't access
memory.
<rdar://problem/10070234>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139319 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/Builtins.def | 18 | ||||
-rw-r--r-- | test/CodeGen/builtin-attributes.c | 41 |
2 files changed, 50 insertions, 9 deletions
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index 50cf872668..b8916d23e0 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -97,9 +97,9 @@ BUILTIN(__builtin_fabsl, "LdLd", "ncF") BUILTIN(__builtin_fmod , "ddd" , "Fnc") BUILTIN(__builtin_fmodf, "fff" , "Fnc") BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc") -BUILTIN(__builtin_frexp , "ddi*" , "Fnc") -BUILTIN(__builtin_frexpf, "ffi*" , "Fnc") -BUILTIN(__builtin_frexpl, "LdLdi*", "Fnc") +BUILTIN(__builtin_frexp , "ddi*" , "Fn") +BUILTIN(__builtin_frexpf, "ffi*" , "Fn") +BUILTIN(__builtin_frexpl, "LdLdi*", "Fn") BUILTIN(__builtin_huge_val, "d", "nc") BUILTIN(__builtin_huge_valf, "f", "nc") BUILTIN(__builtin_huge_vall, "Ld", "nc") @@ -109,9 +109,9 @@ BUILTIN(__builtin_infl , "Ld" , "nc") BUILTIN(__builtin_ldexp , "ddi" , "Fnc") BUILTIN(__builtin_ldexpf, "ffi" , "Fnc") BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc") -BUILTIN(__builtin_modf , "ddd*" , "Fnc") -BUILTIN(__builtin_modff, "fff*" , "Fnc") -BUILTIN(__builtin_modfl, "LdLdLd*", "Fnc") +BUILTIN(__builtin_modf , "ddd*" , "Fn") +BUILTIN(__builtin_modff, "fff*" , "Fn") +BUILTIN(__builtin_modfl, "LdLdLd*", "Fn") BUILTIN(__builtin_nan, "dcC*" , "ncF") BUILTIN(__builtin_nanf, "fcC*" , "ncF") BUILTIN(__builtin_nanl, "LdcC*", "ncF") @@ -234,9 +234,9 @@ BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fnc") BUILTIN(__builtin_remainder , "ddd", "Fnc") BUILTIN(__builtin_remainderf, "fff", "Fnc") BUILTIN(__builtin_remainderl, "LdLdLd", "Fnc") -BUILTIN(__builtin_remquo , "dddi*", "Fnc") -BUILTIN(__builtin_remquof, "fffi*", "Fnc") -BUILTIN(__builtin_remquol, "LdLdLdi*", "Fnc") +BUILTIN(__builtin_remquo , "dddi*", "Fn") +BUILTIN(__builtin_remquof, "fffi*", "Fn") +BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn") BUILTIN(__builtin_rint , "dd", "Fnc") BUILTIN(__builtin_rintf, "ff", "Fnc") BUILTIN(__builtin_rintl, "LdLd", "Fnc") diff --git a/test/CodeGen/builtin-attributes.c b/test/CodeGen/builtin-attributes.c index 822b8eecf7..3781eba266 100644 --- a/test/CodeGen/builtin-attributes.c +++ b/test/CodeGen/builtin-attributes.c @@ -15,3 +15,44 @@ void f1() { char* f2(char* a, char* b) { return __builtin_strstr(a, b); } + +// frexp is NOT readnone. It writes to its pointer argument. +// <rdar://problem/10070234> +// +// CHECK: f3 +// CHECK: call double @frexp(double % +// CHECK-NOT: readnone +// CHECK: call float @frexpf(float % +// CHECK-NOT: readnone +// CHECK: call double @frexpl(double % +// CHECK-NOT: readnone +// +// Same thing for modf and friends. +// +// CHECK: call double @modf(double % +// CHECK-NOT: readnone +// CHECK: call float @modff(float % +// CHECK-NOT: readnone +// CHECK: call double @modfl(double % +// CHECK-NOT: readnone +// +// CHECK: call double @remquo(double % +// CHECK-NOT: readnone +// CHECK: call float @remquof(float % +// CHECK-NOT: readnone +// CHECK: call double @remquol(double % +// CHECK-NOT: readnone +// CHECK: ret +int f3(double x) { + int e; + __builtin_frexp(x, &e); + __builtin_frexpf(x, &e); + __builtin_frexpl(x, &e); + __builtin_modf(x, &e); + __builtin_modff(x, &e); + __builtin_modfl(x, &e); + __builtin_remquo(x, x, &e); + __builtin_remquof(x, x, &e); + __builtin_remquol(x, x, &e); + return e; +} |