Author: Fangrui Song Date: 2023-10-23T18:26:08-07:00 New Revision: d5b0ad632657a598f99bdab64a178015c6ea4b11
URL: https://github.com/llvm/llvm-project/commit/d5b0ad632657a598f99bdab64a178015c6ea4b11 DIFF: https://github.com/llvm/llvm-project/commit/d5b0ad632657a598f99bdab64a178015c6ea4b11.diff LOG: -fstack-usage: fix filename for functions in an included file (#69896) Fix #69889 Added: Modified: clang/test/CodeGen/stack-usage.c llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/stack-usage.c b/clang/test/CodeGen/stack-usage.c index f7dc486c500586b..c9f495605fefd92 100644 --- a/clang/test/CodeGen/stack-usage.c +++ b/clang/test/CodeGen/stack-usage.c @@ -1,17 +1,20 @@ // REQUIRES: aarch64-registered-target -// RUN: rm -rf %t && mkdir %t && cd %t -// RUN: %clang_cc1 -triple aarch64-unknown -stack-usage-file b.su -emit-obj %s -o b.o -// RUN: FileCheck %s < b.su +// RUN: rm -rf %t && split-file %s %t && cd %t +// RUN: %clang_cc1 -triple aarch64-unknown -I . -stack-usage-file a.su -emit-obj a.c -o a.o +// RUN: FileCheck %s < a.su -// CHECK: stack-usage.c:[[#@LINE+1]]:foo {{[0-9]+}} static +// CHECK: {{.*}}x.inc:1:bar [[#]] dynamic +// CHECK: a.c:2:foo [[#]] static +//--- a.c +#include "x.inc" int foo() { char a[8]; return 0; } -// CHECK: stack-usage.c:[[#@LINE+1]]:bar {{[0-9]+}} dynamic +//--- x.inc int bar(int len) { char a[len]; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 072c55f79caa9dc..b1a670fa3c2555c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1469,9 +1469,10 @@ void AsmPrinter::emitStackUsage(const MachineFunction &MF) { } } - *StackUsageStream << MF.getFunction().getParent()->getName(); if (const DISubprogram *DSP = MF.getFunction().getSubprogram()) - *StackUsageStream << ':' << DSP->getLine(); + *StackUsageStream << DSP->getFilename() << ':' << DSP->getLine(); + else + *StackUsageStream << MF.getFunction().getParent()->getName(); *StackUsageStream << ':' << MF.getName() << '\t' << StackSize << '\t'; if (FrameInfo.hasVarSizedObjects()) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits