-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Show zero coverage for unreachable blocks (e.g., dropped after const evaluation) #84018
Comments
I think the easiest way to resolve this would be to just disable simplification of unreachable blocks (due to const eval), if Is there an option for that? I haven't looked yet. |
Replying to my own question: This would not have worked. I noticed (and found in-code comments to confirm) that dead code cannot be left in the MIR. But I solved this in a better way (see PR #84797) by simply saving coverage code regions from dropped |
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? `@tmandry` cc: `@wesleywiser`
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? ``@tmandry`` cc: ``@wesleywiser``
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? ```@tmandry``` cc: ```@wesleywiser```
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? ````@tmandry```` cc: ````@wesleywiser````
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? `````@tmandry````` cc: `````@wesleywiser`````
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? ``````@tmandry`````` cc: ``````@wesleywiser``````
…nts, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR. I also addressed an outstanding issue/request to move coverage tests from run-make-fulldeps to run-make (in commit 2). Fixes: rust-lang#83830 r? ```````@tmandry``````` cc: ```````@wesleywiser```````
…s, r=tmandry Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR (in [commit 1](rust-lang@0b0d293)). r? `@tmandry` cc: `@wesleywiser`
Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR.
Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. Generators clone blocks, so CFG simplification is used to remove the original `BasicBlocks`; and since they were cloned, the original blocks should not be saved. (Saving them resulted in duplicate coverage counters, and `llvm-cov` failed with a "Malformed coverage data" error. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks_with_coverage()`, with `DroppedCoverage::SaveUnreachable`, finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR.
…erage, r=wesleywiser Reland - Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. The prior issues with generators has been resolved and a new test was added to prevent future regressions. Check out the resulting changes to test coverage of dead blocks in the test coverage reports in this PR. r? `@tmandry` fyi: `@wesleywiser`
…age, r=wesleywiser Reland - Report coverage `0` of dead blocks Fixes: rust-lang#84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. Note, this PR relands an earlier, reverted PR that failed when compiling generators. The prior issues with generators has been resolved and a new test was added to prevent future regressions. Check out the resulting changes to test coverage of dead blocks in the test coverage reports in this PR. r? `@tmandry` fyi: `@wesleywiser`
Source-based code coverage (via
-Z instrument-coverage
) does not show coverage for unreachable blocks that were optimized out during MIR transformations. For example:Ideally the second line would show a coverage execution count of
0
, but, assuming this snippet is executed, it would instead show something like:The coverage percentage for this block would be computed as 100%, but should be about 66% (by lines covered).
The MIR
InstrumentCoverage
pass is performed before MIR optimizations, so the coverage instrumentation is available in MIR for line 2. However, subsequent optimizations drop the MIR block, including the coverageStatement
before the codegen phase. The coverage map is generated during codegen, and can usetcx
queries to extract data from theoptimized_mir()
, but that version of the MIR has already been purged of the unreachable blocks.As far as I can tell,
tcx
queries for intermediate MIR representations (for example,tcx.mir_promoted()
) are not available at codegen (they have already been "stolen" by the optimization passes).To solve this problem, I believe I need to cache at least the coverage statements (or their data at least) for the pre-optimized MIR, before those statements are potentially dropped by subsequent MIR passes.
cc: @tmandry @wesleywiser
The text was updated successfully, but these errors were encountered: