Skip to content

Emit coverage mappings for all modules #32216

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
merged 1 commit into from
Jun 10, 2020
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() {}
12 changes: 12 additions & 0 deletions test/Profiler/coverage_num_threads.swift
Original file line number Diff line number Diff line change
@@ -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 ="
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way other than -num-threads to control how files are split up into different modules (maybe @eeckstein knows)?

The issue on Windows appears to be that only the IR for one of the modules is printed out. The first '@__llvm_coverage_mapping =' definition is matched, but the second isn't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're able to quickly test this (I'm spinning up a windows env now) does changing the thread count to 1 change this behavior? I originally did 2 just to make it super clear it was going through the multi-threaded path but 1 also does, so if that affected this that test would still be valid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have access to a Windows environment right now. And I'm not sure I follow your comment here: why should swift only emit the IR for one module, given two source files and -num-threads=2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm definitely not saying it should, it sounds like a bug in -emit-ir only for windows to me, so I was just thinking maybe 1 would avoid that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For historians this was re-merged here #32352


// MULTIPLE-OBJECTS: llvm_coverage_mapping =
// MULTIPLE-OBJECTS: llvm_coverage_mapping =