Ryan Santhirarajan via llvm-dev
2021-May-06 01:31 UTC
[llvm-dev] Implementing "-Wstack-usage=" warning flag
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>
David Blaikie via llvm-dev
2021-May-06 01:55 UTC
[llvm-dev] Implementing "-Wstack-usage=" warning flag
+Roman Lebedev Roman - what was your particular motivation for filing the bug? Is there a use case that -Wframe-larger-than doesn't cover? Would -Wstack-usage as an alias for -Wframe-larger-than be adequate for your use case (if directly using the existing flag is not sufficient for some reason)? On Wed, May 5, 2021 at 6:32 PM Ryan Santhirarajan via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > 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 > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev