[PATCH] D12922: Add support for function attribute "notail"

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 09:55:19 PDT 2015


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.

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