-
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
Run const_prop_lint in check builds, too #120687
Conversation
r? @fmease (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Run const_prop_lint in check builds, too implements rust-lang#108730 (comment) Turns the const_prop_lint pass into a query that is run alongside borrowck.
compiler/rustc_abi/src/layout.rs
Outdated
_ => assert!( | ||
start == Bound::Unbounded && end == Bound::Unbounded, | ||
"nonscalar layout for layout_scalar_valid_range type: {st:#?}", | ||
), | ||
_ => { | ||
if start != Bound::Unbounded || end != Bound::Unbounded { | ||
return None; | ||
} | ||
} |
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.
Can be reverted, this is hit when rustc_scalar_layout_start
is used on structs with a non-scalar field. We can just stop testing that. It's all unstable anyway.
// If there are impossible bounds on the body being const prop linted, | ||
// the const eval logic used in const prop may ICE unexpectedly. | ||
let predicates = tcx | ||
.predicates_of(body.source.def_id()) | ||
.predicates | ||
.iter() | ||
.filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); | ||
if !traits::impossible_predicates(tcx, traits::elaborate(tcx, predicates).collect()) |
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.
This duplication is somewhat unfortunate. We could make const_prop_lint
return whether there were impossible predicates and then bail out.
Or we perform this in borrowck and store the information in borrowck results.
If perf doesn't find this problematic, we could just deduplicate by moving the logic into a function
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.
It may be interesting to look at error taint before trying to check for impossible predicates, as that's faster.
IIUC, this impossible predicates check is more of a heuristic to avoid diagnostic spam, as it does not try to prove satisfiability, does it?
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.
It may be interesting to look at error taint before trying to check for impossible predicates, as that's faster.
there are no errors usually. With trivial_bounds
you may have a broken function that will only error if called, never out of another reason.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -394,6 +395,27 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { | |||
body | |||
} | |||
|
|||
fn const_prop_lint(tcx: TyCtxt<'_>, def: LocalDefId) { |
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.
Can we use this as an opportunity to use a better name? lint_arithmetic_overflow
?
@rust-timer build 63a199c |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (63a199c): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 660.166s -> 662.022s (0.28%) |
Lower mean and max regression in primary benchmarks than #108730 (comment) But all that extra work is going to cost us some perf in check builds, no matter what. |
most of the cost is in |
Any idea why we call |
The difference is that we didn't (reliably) run const prop lints in check builds at all before this PR. Now we do. So a regression due to extra work is expected. |
☔ The latest upstream changes (presumably #120558) made this pull request unmergeable. Please resolve the merge conflicts. |
7a9159b
to
4a6ca9f
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
4a6ca9f
to
f271893
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Run const_prop_lint in check builds, too implements rust-lang#108730 (comment) Turns the const_prop_lint pass into a query that is run alongside borrowck.
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (460bf3d): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 662.662s -> 663.487s (0.12%) |
Looks like all the regressions are legit. Check builds now actually running the lints or non-check-builds in incremental doing some incremental cache loading that they didn't do before |
f271893
to
6add19d
Compare
I haven't reviewed this yet since I'm assuming this is effectively
S-waiting-on-author
|
Oh I basically think the regression cannot be avoided 😆 Either we emit those lints in check builds, and thus take a perf hit on check builds, or we decide to take the check vs build difference in lints. cc @nnethercote because you expressed concerns about perf regressions due to such changes. |
implements #108730 (comment)
addresses a large part of #49292
Turns the const_prop_lint pass into a query that is run alongside borrowck.