Skip to content

Commit 8215ea1

Browse files
committed
Emit coverage mappings for all modules
Previously in WMO builds where IR was multithreaded only the primary module would emit the coverage mapping leading to only the first object file to have the __llvm_covmap section. This change emits coverage for all modules so they are correctly reflected in the final coverage report.
1 parent b5d6652 commit 8215ea1

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,11 @@ void IRGenerator::emitGlobalTopLevel(llvm::StringSet<> *linkerDirectives) {
11051105
IGM->emitSILDifferentiabilityWitness(&dw);
11061106
}
11071107

1108-
// Emit code coverage mapping data.
1109-
PrimaryIGM->emitCoverageMapping();
1108+
// Emit code coverage mapping data for all modules
1109+
for (auto Iter : *this) {
1110+
IRGenModule *IGM = Iter.second;
1111+
IGM->emitCoverageMapping();
1112+
}
11101113

11111114
for (auto Iter : *this) {
11121115
IRGenModule *IGM = Iter.second;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
func func1() {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
func func2() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -num-threads 0 -emit-ir %S/Inputs/coverage_num_threads1.swift | %FileCheck %s -check-prefix=SINGLE-SOURCE --implicit-check-not="llvm_coverage_mapping ="
2+
3+
// SINGLE-SOURCE: llvm_coverage_mapping =
4+
5+
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -num-threads 0 -emit-ir %S/Inputs/coverage_num_threads1.swift %S/Inputs/coverage_num_threads2.swift | %FileCheck %s -check-prefix=SINGLE-OBJECT --implicit-check-not="llvm_coverage_mapping ="
6+
7+
// SINGLE-OBJECT: llvm_coverage_mapping =
8+
9+
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -num-threads 2 -emit-ir %S/Inputs/coverage_num_threads1.swift %S/Inputs/coverage_num_threads2.swift | %FileCheck %s -check-prefix=MULTIPLE-OBJECTS --implicit-check-not="llvm_coverage_mapping ="
10+
11+
// MULTIPLE-OBJECTS: llvm_coverage_mapping =
12+
// MULTIPLE-OBJECTS: llvm_coverage_mapping =

0 commit comments

Comments
 (0)