[llvm] 7994dac - [AsmPrinter] Add a command-line option to emit stack usage files (#178908)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 10:10:13 PST 2026
Author: Marina Taylor
Date: 2026-01-30T18:10:08Z
New Revision: 7994daccd9241837740170457f2736778c294a23
URL: https://github.com/llvm/llvm-project/commit/7994daccd9241837740170457f2736778c294a23
DIFF: https://github.com/llvm/llvm-project/commit/7994daccd9241837740170457f2736778c294a23.diff
LOG: [AsmPrinter] Add a command-line option to emit stack usage files (#178908)
Preparation for #178005.
This will allow stack usage files to be requested during the linking
step in LTO builds, in a more straightforward way than via
TargetOptions.
Added:
llvm/test/CodeGen/X86/stack-usage-file.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index b64c7f5b44033..b10c9194241eb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -192,6 +192,11 @@ static cl::opt<bool> PrintLatency(
cl::desc("Print instruction latencies as verbose asm comments"), cl::Hidden,
cl::init(false));
+static cl::opt<std::string>
+ StackUsageFile("stack-usage-file",
+ cl::desc("Output filename for stack usage information"),
+ cl::value_desc("filename"), cl::Hidden);
+
extern cl::opt<bool> EmitBBHash;
STATISTIC(EmittedInsts, "Number of machine instrs printed");
@@ -1672,7 +1677,9 @@ void AsmPrinter::emitStackSizeSection(const MachineFunction &MF) {
}
void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
- const std::string &OutputFilename = MF.getTarget().Options.StackUsageFile;
+ const std::string OutputFilename =
+ !StackUsageFile.empty() ? StackUsageFile
+ : MF.getTarget().Options.StackUsageFile;
// OutputFilename empty implies -fstack-usage is not passed.
if (OutputFilename.empty())
diff --git a/llvm/test/CodeGen/X86/stack-usage-file.ll b/llvm/test/CodeGen/X86/stack-usage-file.ll
new file mode 100644
index 0000000000000..67ee5d6ba94cb
--- /dev/null
+++ b/llvm/test/CodeGen/X86/stack-usage-file.ll
@@ -0,0 +1,12 @@
+; RUN: llc < %s -mtriple=x86_64 -stack-usage-file=%t.su
+; RUN: FileCheck --input-file=%t.su %s
+
+declare void @g(ptr)
+
+define void @f() {
+ %a = alloca [64 x i8]
+ call void @g(ptr %a)
+ ret void
+}
+
+; CHECK: f [[#]] static
More information about the llvm-commits
mailing list