[PATCH] D100509: Support GCC's -fstack-usage flag

Pengxuan Zheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 15 10:32:20 PDT 2021


pzheng added a comment.

In D100509#2692127 <https://reviews.llvm.org/D100509#2692127>, @xbolva00 wrote:

>>> <source_file>:<line_number>:<function_name> <size_in_byte> <static/dynamic>
>
> gcc also supports "bounded" - do you plan to somehow handle it? (https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options), eg: parser.c:918:5:parse_statement  48      dynamic,bounded

I actually tried some test cases using GCC and never got it to output "dynamic,bounded." So, not sure how (or when) GCC actually determines a function is dynamic, but bounded. Any idea?



================
Comment at: clang/test/CodeGen/stack-usage.c:7
+// RUN: FileCheck %s < %T/b.su
+// RUN: %clang_cc1 -triple arm-unknown -fstack-usage -fstack-usage=%T/c.su -emit-obj %s -o %T/c.o
+// RUN: FileCheck %s < %T/c.su
----------------
xbolva00 wrote:
> -fstack-usage=file.su is Clang only, right? Tried with GCC, gcc error: unrecognized command-line option ‘-fstack-usage=xxx’,
> 
> Do we need to also specify extra -fstack-usage if -fstack-usage=file.su  is used? Seems quite redudant and -fstack-usage=file.su alone should be enough.
Yes, -fstack-usage=file.su is Clang only and it is only a cc1 option, **not ** a driver option. The main reason why I added both flags is to distinguish between the case where the user specified "-o" and the case where "-o" is not specified.

If only -fstack-usage is passed to cc1, we know the user did not pass "-o" on the command line and the name (with the extension removed) of the source file should be used to name the .su file. For example, with "clang -fstack-usage -c foo.c", foo.su is generated.

If both -fstack-usage and -fstack-usage= are present, we know the user specified "-o" and the name of the .su file should be based on that name instead. For example, with "clang -fstack-usage -c foo.c -o bar.o", bar.su is generated instead of foo.su.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509



More information about the cfe-commits mailing list