[PATCH] D12922: Add support for function attribute "notail"
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 20:10:31 PDT 2015
> On 2015-Oct-13, at 09:55, Aaron Ballman <aaron.ballman at gmail.com> wrote:
>
> aaron.ballman added a comment.
>
> In http://reviews.llvm.org/D12922#265452, @ahatanak wrote:
>
>> I think there are a couple of things that have to be discussed:
>>
>> 1. Name of the attribute: Should it be "notail" or "notailcall"? Perhaps it should be named something like "nodirecttail" to indicate it is used to block direct calls, but not indirect calls?
>
>
> The attribute prevents tail calls from the call site, not for the function itself. "notail", at least to me, implies that the function definition itself will not have TCO; it does not imply that callers will be affected. Perhaps "not_tail_called" or "disable_tail_calls"? It's a hard concept to get across in a small identifier.
Note that LLVM has an IR-level attribute called "disabletailcails" that implies that the function definition itself will not have TCO.
I like notailcall because of its relation to noinline. They're both structured like "no<someverb>", and both apply to what callers can do.
I don't really have a strong opinion though, just sharing those thoughts.
>
> Also, I would like to see a test that shows always_inline, notail also gets diagnosed as mutually exclusive, and a test that the right thing happens with a C++ spelling on a member function.
>
> ~Aaron
>
>
> ================
> Comment at: include/clang/Basic/AttrDocs.td:1619
> @@ +1618,3 @@
> + let Content = [{
> +Tail call optimization is not performed on direct calls to a function marked ``notail``.
> + }];
> ----------------
> It would be good to clarify what you mean by direct calls, as not all of the readers are going to understand that easily. Perhaps a simple code example showing a call to the function, and a call to the same function through a function pointer, with comments showing which one has TCO.
>
> You should also call out that it is mutually exclusive with always_inline.
>
> ================
> Comment at: lib/Sema/SemaDeclAttr.cpp:1705
> @@ +1704,3 @@
> +static void handleNoTailAttr(Sema &S, Decl *D, const AttributeList &Attr) {
> + if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr))
> + return;
> ----------------
> Missing the same check in the always_inline attribute handler.
>
>
> http://reviews.llvm.org/D12922
>
>
>
More information about the cfe-commits
mailing list