Skip to content

Commit ba04b71

Browse files
authored
Merge pull request #5376 from modocache/sr-2855-bitcode-wmo
[Driver] Show incremental is off with bitcode, WMO
2 parents 7d9cd11 + 847278e commit ba04b71

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

lib/Driver/Driver.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,22 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
413413
bool ShowIncrementalBuildDecisions =
414414
ArgList->hasArg(options::OPT_driver_show_incremental);
415415

416-
bool Incremental = ArgList->hasArg(options::OPT_incremental) &&
417-
!ArgList->hasArg(options::OPT_whole_module_optimization) &&
418-
!ArgList->hasArg(options::OPT_embed_bitcode);
416+
bool Incremental = ArgList->hasArg(options::OPT_incremental);
417+
if (ArgList->hasArg(options::OPT_whole_module_optimization)) {
418+
if (Incremental && ShowIncrementalBuildDecisions) {
419+
llvm::outs() << "Incremental compilation has been disabled, because it "
420+
<< "is not compatible with whole module optimization.";
421+
}
422+
Incremental = false;
423+
}
424+
if (ArgList->hasArg(options::OPT_embed_bitcode)) {
425+
if (Incremental && ShowIncrementalBuildDecisions) {
426+
llvm::outs() << "Incremental compilation has been disabled, because it "
427+
<< "is not currently compatible with embedding LLVM IR "
428+
<< "bitcode.";
429+
}
430+
Incremental = false;
431+
}
419432

420433
bool SaveTemps = ArgList->hasArg(options::OPT_save_temps);
421434
bool ContinueBuildingAfterErrors =

test/Driver/Dependencies/Inputs/update-dependencies.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535

3636
assert sys.argv[1] == '-frontend'
3737

38-
if '-primary-file' in sys.argv:
38+
# NB: The bitcode options automatically specify a -primary-file, even in cases
39+
# where we do not wish to use a dependencies file in the test.
40+
if '-primary-file' in sys.argv \
41+
and '-embed-bitcode' not in sys.argv and '-emit-bc' not in sys.argv:
3942
primaryFile = sys.argv[sys.argv.index('-primary-file') + 1]
4043
depsFile = sys.argv[sys.argv.index(
4144
'-emit-reference-dependencies-path') + 1]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Test that when:
2+
//
3+
// 1. Using -incremental -v -driver-show-incremental, but...
4+
// 2. ...options that disable incremental compilation, such as whole module
5+
// optimization or bitcode embedding are specified...
6+
//
7+
// ...then the driver prints a message indicating that incremental compilation
8+
// is disabled. If both are specified, the driver should only print one message.
9+
10+
11+
// RUN: rm -rf %t && cp -r %S/Inputs/one-way/ %t
12+
// RUN: %S/Inputs/touch.py 443865900 %t/*
13+
// RUN: echo '{version: "'$(%swiftc_driver_plain -version | head -n1)'", inputs: {"./main.swift": [443865900, 0], "./other.swift": [443865900, 0]}}' > %t/main~buildrecord.swiftdeps
14+
15+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-INCREMENTAL %s
16+
// CHECK-INCREMENTAL-NOT: Incremental compilation has been disabled
17+
// CHECK-INCREMENTAL: Queuing main.swift (initial)
18+
19+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -whole-module-optimization -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-WMO %s
20+
// CHECK-WMO: Incremental compilation has been disabled{{.*}}whole module optimization
21+
// CHECK-WMO-NOT: Queuing main.swift (initial)
22+
23+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -embed-bitcode -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-BITCODE %s
24+
// CHECK-BITCODE: Incremental compilation has been disabled{{.*}}LLVM IR bitcode
25+
// CHECK-BITCODE-NOT: Queuing main.swift (initial)
26+
27+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path %S/Inputs/update-dependencies.py -c ./main.swift ./other.swift -module-name main -incremental -v -driver-show-incremental -whole-module-optimization -embed-bitcode -output-file-map %t/output.json | %FileCheck --check-prefix CHECK-WMO-AND-BITCODE %s
28+
// CHECK-WMO-AND-BITCODE: Incremental compilation has been disabled{{.*}}whole module optimization
29+
// CHECK-WMO-AND-BITCODE-NOT: Incremental compilation has been disabled
30+
// CHECK-WMO-AND-BITCODE-NOT: Queuing main.swift (initial)
31+

0 commit comments

Comments
 (0)