Skip to content
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

[Coverage][MCDC] Do not initialize mcdc parameters for instances containing no mcdc statements #129989

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Lambdaris
Copy link

@Lambdaris Lambdaris commented Sep 5, 2024

This patch fixes possible panics when compiling with mcdc instruments.

The trace of the panic is:

  1. The compiler inserts mcdc statements and fullfill function_coverage_info in pass InstrumentCoverage.
  2. In pass StateTransform, a new DropGlue instance is created at create_coroutine_drop_shim, where function_coverage_info is cloned. Then at remove_dead_blocks, all coverage statements are removed.
  3. In init_coverage the compiler inserts intrinsic instrprof.mcdc.parameters since the DropGlue instance has function_coverage_info with positive mcdc_bitmap_bytes. Note this instance has no coverage statements, so there are no other profiling intrinsics inserted later.
  4. In containsProfilingIntrinsics, llvm possibly finds that the module containing the illformed instance has no expected profiling instrinsics, thus it early returns in InstrLowerer::lower, leaving instrprof.mcdc.parameters unchanged. (The expected instrinsics are declared once there is a instance lowering statement CounterIncrement. However if the module unluckily had no such instance, llvm definitely can not find those intrinsics)
  5. Finally llvm visits intrprof.mcdc.paratemers at codegen, and reaches the unexpected case in SelectionDAGBuilder::visitIntrinsicCall.

These kind of panics may disappear with change of the value passed to -C metadata, because the metadata hash affects sort of instances hence such instances can be grouped with other instrumented instances together into a codegen unit in which llvm can find instrprof.increment at step 4.

@rustbot
Copy link
Collaborator

rustbot commented Sep 5, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nnethercote (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 5, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 5, 2024

Some changes occurred in coverage instrumentation.

cc @Zalathar

@Lambdaris
Copy link
Author

Lambdaris commented Sep 5, 2024

@rustbot label +A-code-coverage
r? Zalathar

@rustbot rustbot added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Sep 5, 2024
@rustbot rustbot assigned pnkfelix and unassigned nnethercote Sep 5, 2024
@rustbot rustbot assigned Zalathar and unassigned pnkfelix Sep 7, 2024
@bors
Copy link
Contributor

bors commented Sep 23, 2024

☔ The latest upstream changes (presumably #130724) made this pull request unmergeable. Please resolve the merge conflicts.

@Lambdaris
Copy link
Author

In case this pr was missed, @Zalathar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants