[llvm-dev] Implementing "-Wstack-usage=" warning flag

Ryan Santhirarajan via llvm-dev llvm-dev at lists.llvm.org
Wed May 5 18:31:49 PDT 2021


Hello everyone,

I am trying to address the following bug:
https://bugs.llvm.org/show_bug.cgi?id=44418
Which asks for the implementation of the missing "-Wstack-usage=" which will report, on a per-function basis, if the stack usage exceeds the user input.

My first approach at implementing "-Wstack-usage" is the following:
https://reviews.llvm.org/D101965
This is virtually identical to the output of "-Wframe-larger-than" on clang. However when observing the behaviour of GCC I noticed that GCC outputs different values for "-Wstack-usage" and "-Wframe-larger-than".

This led me to my second approach which changes the way clang reports "-Wframe-larger-than". This can be found here:
https://reviews.llvm.org/D101964
With this second approach, "-Wframe-larger-than" now reports the stack size minus any space allocated on the stack for the parameters of called functions. This more closely resembles GCC's behaviour.

I am unsure which implementation is preferred/correct and I am wondering if anyone can comment or provide some information on what a better approach would be, and what exactly the two flags should be reporting.

Thanks,
Ryan Santhirarajan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210506/1a75ef0a/attachment.html>


More information about the llvm-dev mailing list