-
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: Clean up creation of MC/DC condition bitmaps #124555
Conversation
r? @nnethercote rustbot has assigned @nnethercote. Use |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
LGTM 👍 |
That value is used for both local variable and parameter alignment. However, this coverage code doesn't actually generate local variables (in the Rust sense of I see some stores changed in this PR to match the hardcoded |
Yeah, I'll need to look inside It looks like they're using |
OK, it looks like the intrinsics are producing stores that don't specify an alignment, which means it defaults to the ABI alignment of the type. So I should revert my alignment changes, and keep using the ABI alignment for i32, as before. Thanks for the correction. |
Back to using I don't need to add an |
Because this now always takes place at the start of the function, we can just use the normal `alloca` method and then initialize each bitmap immediately. This patch also moves bitmap setup out of the `mcdc_parameters` method, because there is no longer any particular reason for it to be there.
This clearly distinguishes individual decision-depth indices from the total number of condition bitmaps to allocate.
I don't know anything about this code, but
So, seems ok to me. My only suggestion is to update the PR description to remove the bit about the memory alignment. Because the PR description is used as the merge commit, so it's best for that to not contain out-of-date information. With that change made, r=me. @bors delegate=Zalathar |
✌️ @Zalathar, you can now approve this pull request! If @nnethercote told you to " |
Good catch; I've removed the old information from the PR description. |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#122492 (Implement ptr_as_ref_unchecked) - rust-lang#123815 (Fix cannot usage in time.rs) - rust-lang#124059 (default_alloc_error_hook: explain difference to default __rdl_oom in alloc) - rust-lang#124510 (Add raw identifier in a typo suggestion) - rust-lang#124555 (coverage: Clean up creation of MC/DC condition bitmaps) - rust-lang#124593 (Describe and use CStr literals in CStr and CString docs) - rust-lang#124630 (CI: remove `env-x86_64-apple-tests` YAML anchor) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124555 - Zalathar:init-coverage, r=nnethercote coverage: Clean up creation of MC/DC condition bitmaps This PR improves the code for creating and initializing [MC/DC](https://en.wikipedia.org/wiki/Modified_condition/decision_coverage) condition bitmap variables, as introduced by rust-lang#123409 and modified by rust-lang#124255. - The condition bitmap variables are now created eagerly at the start of per-function codegen, via a new `init_coverage` method in `CoverageInfoBuilderMethods`. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement. - As a result, we can now create and initialize those bitmaps using existing safe APIs, instead of having to perform our own unsafe call to `llvm::LLVMBuildAlloca`. - This PR also tweaks the way we count the number of condition bitmaps needed, by tracking the total number of bitmaps needed (max depth + 1), instead of only tracking the maximum depth. This reduces the potential for subtle off-by-one confusion.
This PR improves the code for creating and initializing MC/DC condition bitmap variables, as introduced by #123409 and modified by #124255.
init_coverage
method inCoverageInfoBuilderMethods
. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement.llvm::LLVMBuildAlloca
.