WIP - Changes to try to fix and reland cover unreachable statements#85210
Closed
richkadel wants to merge 3 commits intorust-lang:masterfrom
Closed
WIP - Changes to try to fix and reland cover unreachable statements#85210richkadel wants to merge 3 commits intorust-lang:masterfrom
richkadel wants to merge 3 commits intorust-lang:masterfrom
Conversation
added 3 commits
May 11, 2021 13:17
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.
...by saving dead counters/expressions.
Unfortunately, I'm still getting the same result, when trying to get
coverage from Fuchsia apps (at least those using fuchsia_async, but that
may not be the specific cause):
When running `llvm-cov` to get the coverage report, I get the well known
and still useless message:
```
Failed to load coverage: Malformed instrumentation profile data
```
I can change CoverageMappingReader.cpp to avoid failing and I will see
some coverage results (maybe most of the coverage results) but there is
missing coverage as well. I don't know why the function name is not
found.
The "hack" is, change this:
```c++
if (Error Err = CFR->template getFuncName<Endian>(ProfileNames, FuncName))
return Err;
if (FuncName.empty())
return make_error<InstrProfError>(instrprof_error::malformed);
++CovMapNumUsedRecords;
```
to this:
```c++
if (Error Err = CFR->template getFuncName<Endian>(ProfileNames, FuncName))
return Err;
if (FuncName.empty())
FuncName = "MissingFuncNameForCoverage";
++CovMapNumUsedRecords;
```
I did learn that the original implementation (replacing counters and
expressions with Zero/unreachable counters), so this PR addresses that
issue. I hoped that it would fix the problem, but it didn't.
Specifically regarding the LLVM coverage adjustment (improvement?) made
in this version, compared to the reverted PR (rust-lang#84797):
LLVM requires all counters with code regions be added to the coverage
map. The original dead block fix replaced the counters and expressions
with a Zero (unreachable) code region. This commit saves the original
counter or expression, without adding a statement to increment the
counter for the eliminated dead block.
I ran into an error trying to fix dead block coverage and realized the `coverageinfo` query is getting a different MIR compared to the codegenned MIR, which can sometimes be a problem during mapgen. I changed that query to use the `InstandeDef` (which includes the generic parameter substitutions, prosibly specific to const params) instead of the `DefId` (without unknown/default const substitutions).
Collaborator
|
☔ The latest upstream changes (presumably #85328) made this pull request unmergeable. Please resolve the merge conflicts. |
Author
|
Abandoned in lieu of #85385 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP attempt to add coverage
0of dead blocks...by saving dead counters/expressions.
Unfortunately, I'm still getting the same result, when trying to get
coverage from Fuchsia apps (at least those using fuchsia_async, but that
may not be the specific cause):
When running
llvm-covto get the coverage report, I get the well knownand still useless message:
I can change CoverageMappingReader.cpp to avoid failing and I will see
some coverage results (maybe most of the coverage results) but there is
missing coverage as well. I don't know why the function name is not
found.
The "hack" is, change this:
to this:
I did learn that the original implementation (replacing counters and
expressions with Zero/unreachable counters), so this PR addresses that
issue. I hoped that it would fix the problem, but it didn't.
Specifically regarding the LLVM coverage adjustment (improvement?) made
in this version, compared to the reverted PR (#84797):
LLVM requires all counters with code regions be added to the coverage
map. The original dead block fix replaced the counters and expressions
with a Zero (unreachable) code region. This commit saves the original
counter or expression, without adding a statement to increment the
counter for the eliminated dead block.
r? @tmandry