Skip to content

Commit d5b0ad6

Browse files
authored
-fstack-usage: fix filename for functions in an included file (#69896)
Fix #69889
1 parent 54e46ba commit d5b0ad6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

clang/test/CodeGen/stack-usage.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
// REQUIRES: aarch64-registered-target
22

3-
// RUN: rm -rf %t && mkdir %t && cd %t
4-
// RUN: %clang_cc1 -triple aarch64-unknown -stack-usage-file b.su -emit-obj %s -o b.o
5-
// RUN: FileCheck %s < b.su
3+
// RUN: rm -rf %t && split-file %s %t && cd %t
4+
// RUN: %clang_cc1 -triple aarch64-unknown -I . -stack-usage-file a.su -emit-obj a.c -o a.o
5+
// RUN: FileCheck %s < a.su
66

7-
// CHECK: stack-usage.c:[[#@LINE+1]]:foo {{[0-9]+}} static
7+
// CHECK: {{.*}}x.inc:1:bar [[#]] dynamic
8+
// CHECK: a.c:2:foo [[#]] static
9+
//--- a.c
10+
#include "x.inc"
811
int foo() {
912
char a[8];
1013

1114
return 0;
1215
}
1316

14-
// CHECK: stack-usage.c:[[#@LINE+1]]:bar {{[0-9]+}} dynamic
17+
//--- x.inc
1518
int bar(int len) {
1619
char a[len];
1720

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,9 +1469,10 @@ void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
14691469
}
14701470
}
14711471

1472-
*StackUsageStream << MF.getFunction().getParent()->getName();
14731472
if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
1474-
*StackUsageStream << ':' << DSP->getLine();
1473+
*StackUsageStream << DSP->getFilename() << ':' << DSP->getLine();
1474+
else
1475+
*StackUsageStream << MF.getFunction().getParent()->getName();
14751476

14761477
*StackUsageStream << ':' << MF.getName() << '\t' << StackSize << '\t';
14771478
if (FrameInfo.hasVarSizedObjects())

0 commit comments

Comments
 (0)