Skip to content

reland: Emit coverage mappings for all modules #32352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/Profiler/Inputs/coverage_num_threads1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
func func1() {}
1 change: 1 addition & 0 deletions test/Profiler/Inputs/coverage_num_threads2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
func func2() {}
13 changes: 13 additions & 0 deletions test/Profiler/coverage_num_threads.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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 =

// Using 1 goes down the multithreaded codepath but only operates with a single thread to work around an issue on Windows where the output of both IR modules is interleaved and therefore the output is invalid
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -num-threads 1 -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 =