-
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
Split mcdc code to a sub module of coverageinfo #124399
Conversation
Some changes occurred in coverage instrumentation. cc @Zalathar |
r? @oli-obk |
Hmm, I think I would prefer to leave the main file as Moving the MC/DC code into a subdirectory is still fine, but we should consider delaying this change until after I've had a chance to review and merge #124255, to avoid disturbing that work too much. |
@bors delegate=Zalathar |
I'm not sure whether rustc accept the new module style so I kept it same with other modules. If could the second commit can be dropped.
Sounds fair. |
Some changes occurred in coverage instrumentation. cc @Zalathar Some changes occurred in coverage instrumentation. cc @Zalathar Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in coverage instrumentation. cc @Zalathar Some changes occurred in match lowering cc @Nadrieril Some changes occurred in coverage tests. cc @Zalathar |
☔ The latest upstream changes (presumably #124255) made this pull request unmergeable. Please resolve the merge conflicts. |
d42431b
to
035e0a8
Compare
Would it be reasonable to split this into two commits, so that the first commit adds (Similar to what I've done in #124545, by having a preparation commit first, and then a movement-only commit second.) |
Sure will do |
|
||
use crate::build::{Builder, CFG}; | ||
use crate::errors::MCDCExceedsConditionNumLimit; | ||
use mcdc::MCDCInfoBuilder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please make this use crate::build::coverageinfo::mcdc::MCDCInfoBuilder
, so that all the same-crate imports are consistent.
(I don't think there's an official policy for this formatting, but personally I prefer the consistent style.)
tcx.sess | ||
.instrument_coverage_mcdc() | ||
.then(|| Self { decision_ctx_stack: vec![MCDCDecisionCtx::default()] }) | ||
fn init() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should just be new()
.
I have some suggestions for renaming things. These are just suggestions, so you might disagree.
The reason for these suggestions is that I think the shorter variable names make the code easier to read, and the longer names don't add much useful information. What do you think? |
Agree that |
if let Some(mcdc_info) = self | ||
.coverage_branch_info | ||
.as_mut() | ||
.and_then(|branch_info| branch_info.mcdc_info.as_mut()) | ||
{ | ||
mcdc_state.record_conditions(logical_op, span); | ||
mcdc_info.state.record_conditions(logical_op, span); | ||
} | ||
} | ||
|
||
pub(crate) fn mcdc_increment_depth_if_enabled(&mut self) { | ||
if let Some(branch_info) = self.coverage_branch_info.as_mut() | ||
&& let Some(mcdc_state) = branch_info.mcdc_state.as_mut() | ||
if let Some(mcdc_info) = self | ||
.coverage_branch_info | ||
.as_mut() | ||
.and_then(|branch_info| branch_info.mcdc_info.as_mut()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using let chains (&& let
) here is clearer than using and_then
.
Typo in commit name:
|
I'm not convinced that changing things from |
I change |
OK, this looks good. @bors r=Zalathar |
@rustbot label +A-code-coverage |
☀️ Test successful - checks-actions |
Finished benchmarking commit (47314eb): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 672.74s -> 672.522s (-0.03%) |
A further work from #124217 . I have made relatively large changes when working on #124278 so that it would better split them from
coverageinfo.rs
to avoid potential troubling merge work with improved branch coverage by @Zalathar .Besides
BlockMarkerGenerator
is added to avoid ownership problems (mostly needed for following change of #124278 )All code changes are done in a37d737a while the second commit just renames the file.
cc @RenjiSann @Zalathar
This will impact your current work.