gulfem added inline comments.

================
Comment at: clang/include/clang/Basic/AttrDocs.td:3910
+in library functions. Functions marked with the ``leaf`` attribute are not 
allowed
+to jump back into the caller's translation unit, whether through invoking a
+callback function, a direct external function call, use of ``longjmp``, or 
other means.
----------------
aaron.ballman wrote:
> gulfem wrote:
> > I think this property is transitive. 
> > If a leaf function somehow enters into caller's translation unit (either 
> > via direct call or a via its call chain), it will violate the rule that 
> > says "Calls to external functions with this attribute must return to the 
> > current compilation unit only by return or by exception handling". 
> > Entering via its call chain is not a return or an exception handling.
> > Do you agree with that?
> > I think this property is transitive. ... Do you agree with that?
> 
> That makes sense to me! I think I'd recommend a slight modification to the 
> docs then:
> 
> ```
> Functions marked with the ``leaf`` attribute are not allowed to jump back 
> into the caller's translation unit, whether through invoking a callback 
> function, a direct, possibly transitive, external function call, use of 
> ``longjmp``, or other means.
> ```
> The last question is: by "direct" does the GCC docs imply that calls back to 
> the caller's TU through a function *pointer* are not UB? I'd imagine those 
> would also be bad, but I'd like to make sure (and perhaps we can remove the 
> `direct` from the wording if calls through function pointers are disallowed).
I think the idea is that the control-flow should never come back to the 
caller's translation unit by any kind of control-flow changing mechanism 
(direct/indirect and call/jump).
The compiler might use this hint to do optimizations based on that assumption, 
so the user should ensure that.
Could you please explain what do you mean by calling back via function pointer?
I thought that callback function is basically calling back via a function 
pointer. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to