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

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 15:06:28 PDT 2015


ahatanak updated this revision to Diff 37172.
ahatanak added a comment.

I've made some changes following the discussion I had and the feedback I got on the llvm-side patch.

This is the link to the discussion thread:
http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/271105/

The difference between the previous patch and this patch lies in the way indirect calls (at the source level) are handled. The approach taken in the previous patch attached the notail attribute to the declaration or definition of functions in the IR, which enabled blocking tail call optimization on an indirect call site if the compiler could statically determine it was calling a function marked notail. In this patch, clang marks a call instruction in the IR as notail only if it is a direct call to a function marked "notail". It does nothing to prevent tail call on indirect call sites.

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?

2. Can we guarantee or promise that the attribute will *always* block direct calls (but do nothing for indirect calls)? Or should we say this attribute only prevents tail call (even for direct calls) on a best effort basis in case it turns out there are cases where it isn't possible to keep that promise?


http://reviews.llvm.org/D12922

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-no-tail.c
  test/Sema/attr-notail.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12922.37172.patch
Type: text/x-patch
Size: 3981 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151012/2a183598/attachment.bin>


More information about the cfe-commits mailing list