- 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 well.
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 attribute
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.