rsanthir.quic added inline comments.

================
Comment at: clang/docs/ReleaseNotes.rst:79-80
 
+- ``-Wstack-usage=<byte-size>`` warn if stack usage of user functions might
+  exceed <byte-size>.
+
----------------
Quuxplusone wrote:
> Does this mean:
> - Warn if the size of any single function's stack frame (including 
> temporaries and local variables, but not parameters or return addresses) 
> exceeds <byte-size>.
> - Warn if the size of any single function's stack frame (including parameters 
> and return addresses) exceeds <byte-size>.
> - Warn if the total stack usage of the longest visible call chain in this 
> translation unit might exceed <byte-size>.
> ?
> 
Looking at how the value for this flag is obtained, which is an alias of 
"-Wframe-larger-than", I see that it is all objects placed on the stack by each 
function plus any space reserved for arguments of callsites in the function. 

There is no precise definition of what is included as it depends on the target 
as well as what is stored on the stack or not.

I guess in simplest terms, for each function this will report how much stack 
space is used by that function.



================
Comment at: clang/test/Frontend/backend-stack-usage-diagnostic.c:19-23
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
----------------
Quuxplusone wrote:
> This function has no "stack frame" in the usual sense of the word, because 
> it's just
> ```
>         movl    %edi, %eax
>         imull   %edi, %eax
>         ret
> ```
> So am I correct to infer that the `-Wstack-usage=` option includes the size 
> of the return address in its computations? So the stack usage of this 
> function would be computed as "8 bytes" because the `callq` instruction 
> pushes 8 bytes on the stack?
> This seems eminently reasonable to me, but non-obvious, and should get some 
> user-facing documentation.
When a function stores the return address on the stack, that will be included 
in that functions stack usage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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

Reply via email to