[llvm-dev] [RFC] Leaf Attribute Support in Clang/LLVM

Gulfem Savrun Yeniceri via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 27 17:36:27 PDT 2020

Hi all,



   This RFC proposes adding __attribute__((leaf)) support into Clang/LLVM



   GCC supports __attribute__((leaf)) as an optimization hint described in:



   Fuchsia uses leaf attribute in syscalls, but this attribute is currently
   only supported in GCC.

   We would like to implement support for this attribute in Clang/LLVM as


   This support can benefit Clang/LLVM in two ways:

      Achieve feature parity with GCC

      Compiler hint to improve data-flow analysis

High Level Design (WIP):


   Support __attribute__((leaf)) in Clang

   Add a new LLVM IR attribute called nocallback

   Modify Clang code generator to generate nocallback attribute for leaf

   We choose the name nocallback instead of leaf to avoid confusion. Leaf
   attribute does not necessarily mean leaf function in the sense that it does
   not call any other functions. As stated in GCC manual, leaf functions are
   not allowed to enter their caller's translation unit.

Please let us know about your thoughts regarding this RFC.

I also prepared a patch, so please let us know if you have any feedback.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201027/f7c0a620/attachment.html>

More information about the llvm-dev mailing list