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

PR #84797 causes an ICE in some situations #85081

Closed
richkadel opened this issue May 8, 2021 · 1 comment
Closed

PR #84797 causes an ICE in some situations #85081

richkadel opened this issue May 8, 2021 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@richkadel
Copy link
Contributor

richkadel commented May 8, 2021

PR #84797 (Report coverage 0 of dead blocks, merged on May 7, 2021) replaces any MIR Coverage statement that is about to be dropped during MIR simplification with a CoverageKind::Unreachable statement, and adds that statement to the START_BLOCK. This makes it possible to still add the CodeRegions for the removed (unreachable) code to the coverage map, so they can be reported as unexecuted code.

The MIR InstrumentCoverage pass always adds a CoverageKind::Counter to the START_BLOCK (so if a function is called, it is counted), and I assumed that the START_BLOCK itself could never be simplified away.

However, when compiling some complex async and executor constructions from a large code base, the compiler ICE'd, and I was able to determine that some kind of MIR transform can drop the START_BLOCK, and can generate a final MIR that has all CoverageKind::Counter statements replaced with CoverageKind::Unreachable statements.

The ICE is caused now when a function has CoverageKind::Unreachable statements and no CoverageKind::Counter. At least one CoverageKind::Counter is required, to set the function hash for LLVM InstrProf, and an assert!() fails when generating the coverage map (for the unreachable regions) without this function hash.

A PR that fixes this issue has been uploaded (#85082).

@richkadel richkadel added the C-bug Category: This is a bug. label May 8, 2021
richkadel added a commit to richkadel/rust that referenced this issue May 8, 2021
Fixes: rust-lang#85081

An `assert!()` in `FunctionCoverage` failed, because PR rust-lang#84797
replaces unreachable `Counter`s with `Unreachable` code regions to be
added to the function's coverage map.

To fix it, and still generate valid LLVM coverage IR, convert one
unreachable to a `Counter`.
@richkadel
Copy link
Contributor Author

Fixed via the revert in PR #85196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant