-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
base: master
Are you sure you want to change the base?
Conversation
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 (
|
Some changes occurred in coverage instrumentation. cc @Zalathar |
@rustbot label +A-code-coverage |
☔ The latest upstream changes (presumably #130724) made this pull request unmergeable. Please resolve the merge conflicts. |
48872a1
to
dedae9e
Compare
In case this pr was missed, @Zalathar |
Sorry for the delay. Is there a test case that can trigger this panic in the current compiler? It would be good to have a regression test so that we can modify the code without worrying about breaking things again. |
Have tried but it looks hard. This bug happens only when:
I encountered this issue when compiling |
dedae9e
to
08f0d64
Compare
08f0d64
to
a00c89e
Compare
Check such instances with |
This patch fixes possible panics when compiling with mcdc instruments.
The trace of the panic is:
function_coverage_info
in passInstrumentCoverage
.StateTransform
, a newDropGlue
instance is created atcreate_coroutine_drop_shim
, wherefunction_coverage_info
is cloned. Then atremove_dead_blocks
, all coverage statements are removed.init_coverage
the compiler inserts intrinsicinstrprof.mcdc.parameters
since theDropGlue
instance hasfunction_coverage_info
with positivemcdc_bitmap_bytes
. Note this instance has no coverage statements, so there are no other profiling intrinsics inserted later.containsProfilingIntrinsics
, llvm possibly finds that the module containing the illformed instance has no expected profiling instrinsics, thus it early returns inInstrLowerer::lower
, leavinginstrprof.mcdc.parameters
unchanged. (The expected instrinsics are declared once there is a instance lowering statementCounterIncrement
. However if the module unluckily had no such instance, llvm definitely can not find those intrinsics)intrprof.mcdc.paratemers
at codegen, and reaches the unexpected case inSelectionDAGBuilder::visitIntrinsicCall
.These kind of panics may disappear with change of the value passed to
-C metadata
, because themetadata
hash affects sort of instances hence such instances can be grouped with other instrumented instances together into a codegen unit in which llvm can findinstrprof.increment
at step 4.