diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2015-11-13 00:42:21 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2015-11-13 00:42:21 +0000 |
commit | 361b11dedac9bb7a4860c7895c2b74f052e0470c (patch) | |
tree | 770ff4101bc5ac753b2571e24c63e94b32e69178 /test/Sema | |
parent | e4e016d0a83da8c5a6050129c2ad0648c575046c (diff) | |
download | clang-361b11dedac9bb7a4860c7895c2b74f052e0470c.tar.gz |
Add support for function attribute 'disable_tail_calls'.
The ``disable_tail_calls`` attribute instructs the backend to not
perform tail call optimization inside the marked function.
For example,
int callee(int);
int foo(int a) __attribute__((disable_tail_calls)) {
return callee(a); // This call is not tail-call optimized.
}
Note that this attribute is different from 'not_tail_called', which
prevents tail-call optimization to the marked function.
rdar://problem/8973573
Differential Revision: http://reviews.llvm.org/D12547
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252986 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/attr-disable-tail-calls.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Sema/attr-disable-tail-calls.c b/test/Sema/attr-disable-tail-calls.c new file mode 100644 index 0000000000..4574d5e0b6 --- /dev/null +++ b/test/Sema/attr-disable-tail-calls.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void __attribute__((disable_tail_calls,naked)) foo1(int a) { // expected-error {{'disable_tail_calls' and 'naked' attributes are not compatible}} expected-note {{conflicting attribute is here}} + __asm__(""); +} + +void __attribute__((naked,disable_tail_calls)) foo2(int a) { // expected-error {{'naked' and 'disable_tail_calls' attributes are not compatible}} expected-note {{conflicting attribute is here}} + __asm__(""); +} + +int g0 __attribute__((disable_tail_calls)); // expected-warning {{'disable_tail_calls' attribute only applies to functions and methods}} + +int foo3(int a) __attribute__((disable_tail_calls("abc"))); // expected-error {{'disable_tail_calls' attribute takes no arguments}} |