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

Pengxuan Zheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 14 14:03:58 PDT 2021


pzheng created this revision.
pzheng added reviewers: apazos, efriedma, seaneveson, bruno, MatzeB, hfinkel.
Herald added subscribers: jansvoboda11, dexonsmith, dang, hiraditya.
pzheng requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch adds support for GCC's -fstack-usage flag. With this flag, a stack
usage file (i.e., .su file) is generated for each input source file. The format
of the stack usage file is also similar to what is used by GCC. For each
function defined in the source file, a line with the following information is
produced in the .su file.

<source_file>:<line_number>:<function_name> <size_in_byte> <static/dynamic>

"Static" means that the function's frame size is static and the size info is an
accurate reflection of the frame size. While "dynamic" means the function's
frame size can only be determined at run-time because the function manipulates
the stack dynamically (e.g., due to variable size objects). The size info only
reflects the size of the fixed size frame objects in this case and therefore is
not a reliable measure of the total frame size.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100509

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100509.337553.patch
Type: text/x-patch
Size: 10550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210414/b15e8b8d/attachment-0001.bin>


More information about the cfe-commits mailing list