Skip to content

Commit b52241e

Browse files
committed
Frontend: For whole module compiles, omit filelists from stack dumps.
For batch compile jobs, it's helpful to see which files are considered primary and that was the original reason why filelist contents were printed in compiler crash stack dumps. However, for whole module compile jobs, the contents of the filelist is uninteresting (it's just all the files in the module) and can be hundreds or thousands of lines long so it often causes important information to be trimmed from stack dumps received in reproducers.
1 parent f7342e7 commit b52241e

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,12 +1986,18 @@ int swift::performFrontend(ArrayRef<const char *> Args,
19861986
auto configurationFileStackTraces =
19871987
std::make_unique<std::optional<PrettyStackTraceFileContents>[]>(
19881988
configurationFileBuffers.size());
1989-
for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
1990-
&configurationFileStackTraces[0],
1991-
[](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
1992-
std::optional<PrettyStackTraceFileContents> &trace) {
1993-
trace.emplace(*buffer);
1994-
});
1989+
1990+
// If the compile is a whole module job, then the contents of the filelist
1991+
// is every file in the module, which is not very interesting and could be
1992+
// hundreds or thousands of lines. Skip dumping this output in that case.
1993+
if (!Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule()) {
1994+
for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
1995+
&configurationFileStackTraces[0],
1996+
[](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
1997+
std::optional<PrettyStackTraceFileContents> &trace) {
1998+
trace.emplace(*buffer);
1999+
});
2000+
}
19952001

19962002
// The compiler invocation is now fully configured; notify our observer.
19972003
if (observer) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo %s > %t/filelist.txt
3+
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t/filelist.txt 2>&1 | %FileCheck %s
4+
5+
// CHECK-LABEL: Stack dump
6+
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
7+
// CHECK-NEXT: Swift version
8+
// CHECK-NEXT: Compiling with effective version
9+
10+
// Filelist contents should be omitted since this is a whole-module compile.
11+
// CHECK-NOT: Contents of
12+
13+
func anchor() {}
14+
anchor()

test/Frontend/crash.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
// RUN: echo %s > %t.filelist.txt
2-
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t.filelist.txt 2>&1 | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo %s > %t/primary.filelist.txt
3+
// RUN: echo "" > %t/empty.swift
4+
// RUN: echo "%t/empty.swift" > %t/all.filelist.txt
5+
// RUN: echo %s >> %t/all.filelist.txt
6+
7+
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -primary-filelist %t/primary.filelist.txt -filelist %t/all.filelist.txt 2>&1 | %FileCheck %s
38

49
// Check that we see the contents of the input file list in the crash log.
510
// CHECK-NOT: while allowing modules with compiler errors
611
// CHECK-LABEL: Stack dump
712
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
813
// CHECK-NEXT: Swift version
914
// CHECK-NEXT: Compiling with effective version
10-
// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
15+
// CHECK-NEXT: Contents of {{.*}}/all.filelist.txt:
16+
// CHECK-NEXT: ---
17+
// CHECK-NEXT: {{[\\/]}}empty.swift{{$}}
18+
// CHECK-NEXT: {{[\\/]}}crash.swift{{$}}
19+
// CHECK-NEXT: ---
20+
// CHECK-NEXT: Contents of {{.*}}/primary.filelist.txt:
1121
// CHECK-NEXT: ---
12-
// CHECK-NEXT: test{{[\\/]}}Frontend{{[\\/]}}crash.swift{{$}}
22+
// CHECK-NEXT: {{[\\/]}}crash.swift{{$}}
1323
// CHECK-NEXT: ---
1424

1525
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -experimental-allow-module-with-compiler-errors %s 2>&1 | %FileCheck -check-prefix CHECK-ALLOW %s

0 commit comments

Comments
 (0)