[PATCH] D90275: [clang][IR] Add support for leaf attribute

Gulfem Savrun Yeniceri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 11:11:15 PST 2020


gulfem marked an inline comment as not done.
gulfem added inline comments.


================
Comment at: clang/include/clang/Basic/AttrDocs.td:3909
+The ``leaf`` attribute is used as a compiler hint to improve dataflow analysis in library functions.
+Functions marked as ``leaf`` attribute are not allowed to enter their caller's translation unit.
+Therefore, they cannot use or modify any data that does not escape the current compilation unit.
----------------
aaron.ballman wrote:
> as leaf -> with the leaf
> 
> I'm not certain how to interpret that functions are not allowed to enter their caller's translation unit. I sort of read that as leaf functions are not allowed to call (or otherwise jump) out of the translation unit in which they're defined -- is that about right?
I think the description is a little confusing.
As far as I understand, leaf functions can actually call or jump out the the translation unit that they are defined ("Leaf functions might still call functions from other compilation units").
The manual refers caller function's translation unit as **current translation** unit.
"Calls to external functions with this attribute must return to the current compilation unit only by return or by exception handling. In particular, a leaf function is not allowed to invoke callback functions passed to it from the current compilation unit, directly call functions exported by the unit, or longjmp into the unit."
My interpretation of this statement is that a function marked with a leaf attribute can only return to its caller translation unit by a return or an exception, but it cannot enter into callers translation unit by invoking a callback function. 
Does that make sense?




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90275/new/

https://reviews.llvm.org/D90275



More information about the llvm-commits mailing list