diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 7e6710311b798..9dd9c4944b2c3 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -1105,8 +1105,11 @@ void IRGenerator::emitGlobalTopLevel(llvm::StringSet<> *linkerDirectives) { IGM->emitSILDifferentiabilityWitness(&dw); } - // Emit code coverage mapping data. - PrimaryIGM->emitCoverageMapping(); + // Emit code coverage mapping data for all modules + for (auto Iter : *this) { + IRGenModule *IGM = Iter.second; + IGM->emitCoverageMapping(); + } for (auto Iter : *this) { IRGenModule *IGM = Iter.second; diff --git a/test/Profiler/Inputs/coverage_num_threads1.swift b/test/Profiler/Inputs/coverage_num_threads1.swift new file mode 100644 index 0000000000000..6ca641732e7e1 --- /dev/null +++ b/test/Profiler/Inputs/coverage_num_threads1.swift @@ -0,0 +1 @@ +func func1() {} diff --git a/test/Profiler/Inputs/coverage_num_threads2.swift b/test/Profiler/Inputs/coverage_num_threads2.swift new file mode 100644 index 0000000000000..639ea1b4ad4b7 --- /dev/null +++ b/test/Profiler/Inputs/coverage_num_threads2.swift @@ -0,0 +1 @@ +func func2() {} diff --git a/test/Profiler/coverage_num_threads.swift b/test/Profiler/coverage_num_threads.swift new file mode 100644 index 0000000000000..1a50c76335596 --- /dev/null +++ b/test/Profiler/coverage_num_threads.swift @@ -0,0 +1,12 @@ +// 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 =" + +// SINGLE-SOURCE: llvm_coverage_mapping = + +// 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 =" + +// SINGLE-OBJECT: llvm_coverage_mapping = + +// 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 =" + +// MULTIPLE-OBJECTS: llvm_coverage_mapping = +// MULTIPLE-OBJECTS: llvm_coverage_mapping =