[PATCH] D100509: Support GCC's -fstack-usage flag
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 20 15:35:09 PDT 2021
MaskRay added inline comments.
================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5474
+ if (Args.hasArg(options::OPT_fstack_usage)) {
+ CmdArgs.push_back(Args.MakeArgString("-fstack-usage"));
+
----------------
CC1 needs two options?
If you infer the filename in the driver, CC1 can use "whether StackUsageOutput is empty".
================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5480
+ CmdArgs.push_back(Args.MakeArgString("-fstack-usage=" +
+ std::string(OutputFilename.str())));
+ }
----------------
`"-fstack-usage=" + OutputFilename.str()`
MakeArgString works with a Twine.
================
Comment at: clang/test/CodeGen/stack-usage.c:1
+// REQUIRES: x86-registered-target,aarch64-registered-target,arm-registered-target
+
----------------
Such llvm specific tests break layering but we don't have better way for testing so this might be ok...
However, not sure we need three targets. Usually one is sufficient.
================
Comment at: clang/test/CodeGen/stack-usage.c:3
+
+// RUN: %clang_cc1 -triple x86_64-unknown -fstack-usage -fstack-usage=%T/a.su -emit-obj %s -o %T/a.o
+// RUN: FileCheck %s < %T/a.su
----------------
%T is a deprecated lit replacement. Use `rm -rf %t && mkdir %t`
================
Comment at: clang/test/Driver/stack-usage.c:1
+// RUN: %clang -target x86_64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
+// RUN: %clang -target aarch64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
----------------
Not sure we need three. One suffices.
================
Comment at: clang/test/Driver/stack-usage.c:9
+// RUN: %clang -target arm-unknown -fstack-usage %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: -fstack-usage
+
----------------
Include quotes
================
Comment at: llvm/include/llvm/CodeGen/AsmPrinter.h:179
+ /// Output stream for the stack usage file (i.e., .su file).
+ std::unique_ptr<raw_fd_ostream> StackUsageStream = nullptr;
+
----------------
Delete `= nullptr`
================
Comment at: llvm/include/llvm/Target/TargetOptions.h:350
+ /// for foo.c)
+ std::string StackUsageOutput = "";
+
----------------
Delete `= ""`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100509/new/
https://reviews.llvm.org/D100509
More information about the llvm-commits
mailing list