-
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
Make sure to run all mir analyses in check mode #108730
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 16ea61bc20aae8ce55d264f4dfc5946d96f6d4bb with merge ef6fb91f1639ca8eb8441f20e006ae031ff3aa98... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (ef6fb91f1639ca8eb8441f20e006ae031ff3aa98): 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.
|
cc @tmandry this PR removes a large source of situations where As expected, it is a major regression. This is not changing anything around when PMEs are reported, it's an entirely different issue. |
This comment has been minimized.
This comment has been minimized.
The Miri subtree was changed cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
note: tracking was triggered | ||
| | ||
= note: created extern static allocation of SIZE bytes (alignment ALIGN bytes) with id 1 | ||
= note: (no span available) | ||
|
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'm a bit baffled why this disappears. The test is actually starting MIR interpretation, and there are no allocations beyond the one with id 1
. So my guess is MIR interpretation doesn't create it, but const prop or some other analysis pass does and we just reuse the cached one.
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.
Did AllocIds shift? The PR might evaluate more things earlier now so const-eval uses AllocIds that previously were still available to Miri.
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.
oh 🤦 I didn't go up far enough with the ids, because I started seeing other ids that I thought came later.
…rieb Add regression test for rust-lang#98444 cc rust-lang#108730 this will need to be changed to a `check-fail` test once it lands. Fixes rust-lang#98444
This comment has been minimized.
This comment has been minimized.
Thanks for tagging me! To check my understanding, this is about fixing some (maybe all?) cases of optimization-dependent errors, and the affected errors we're seeing in tests happen to specifically be lints (rather than hard errors)?
I'm not 100% sure what you include when you say PMEs. Can I propose to use the terminology I wrote at the top of this doc: Non-local errors in Rust? In those terms, I think what you're talking about is probably a combination of parameter-dependent errors and use-dependent errors. |
This PR does not affect non-local errors. It just makes sure that at least all lints that operate just on function-local information get emitted. It is a prerequisite to reporting all non-local errors in check mode, as most of these lints will start getting reported if we start reporting non-local errors in check mode. I wanted to open this PR separately so that we can observe the performance changes and diagnostics changes on their own instead of mixing them with the changes that would occur if we reported non-local errors in check mode. |
Thanks, that makes sense. So these lints previously depended on (By the way, I don't feel that strongly about using the term "non-local errors", I care more about splitting out into sub-categories like "CLI-dependent" and "parameter-dependent". If these distinctions don't quite map onto the problem space from your point of view, that would be good to know, but my hope is that everything fits into one or more of those sub-categories.) |
No, these lints are reported for dead code, too. Previously they were only reported for all const items and functions (even those in dead code) |
☔ The latest upstream changes (presumably #108872) made this pull request unmergeable. Please resolve the merge conflicts. |
The lang team discussed this today in our meeting (notes). We agreed that we consider this a bug fix and think it should be merged. After that, we'd like to know how costly it is to go further, eliminating any errors that appear in |
68f22a4
to
de89a48
Compare
r? compiler |
Whoops, wrong issue. i'll search for the right one |
Ah okay. So I'm trying to understand what exactly this diff does: some MIR checks like unsafety, or packed fields, were already run in check builds before. But ConstPropLint was not? Looking at run_analysis_to_runtime_passes and the passes it calls, we are doing a lot of work here that is unnecessary. Ideally we'd run the lints but not all the optimizations. Sadly, |
tcx.ensure() | ||
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::unknown(def_id)); | ||
} | ||
}); |
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 looks pretty similar to the existing MIR_effect_checking
above. Please add comments explaining why there are two of these blocks and what each of them is doing.
yea... that's the question. Where do we draw the line. Right now the line is arbitrary. If we don't want to check more lints, we may want to consider relaxing a few other things in |
I do think it would be valuable to get the const-prop-lints run in check mode. It's not what I would consider a PME, so not having them in check builds is quite surprising. Or put differently: I don't think we should have lints as late in the MIR pipeline as const-pro-lints currently is. We have analysis MIR and runtime MIR, and just conceptually it seems clear that lints should run on analysis MIR, no? |
Unfortunately this quickly causes cycle errors because the only query before that is |
Hm, I see. borrowck being needed for layout is surprising (layout shouldn't depend on lifetimes) but does make this tricky indeed. |
that's actually a very good point... We can grab the types from typeck for layouting, but we need |
Marking this PR as blocked on moving the const prop lint earlier. |
One of the outputs of borrowck is the list of paths captured by a closure, which affects the layout of closures. |
☔ The latest upstream changes (presumably #109884) made this pull request unmergeable. Please resolve the merge conflicts. |
hey 👋 what's the status for this PR? Still cc @oli-obk |
I tried moving const prop earlier, but that is a significant perf regression: #115756 I won't be able to work on this again before January. |
We could run const-prop-lints after borrowck but still as part of analysis MIR -- or does that not help perf-wise? It could be the last pass in analysis MIR. But the point is, it shouldn't be in optimized_mir, as that query (for good reasons) is not fired in |
that's already what's happening. One possibility would be to turn const prop lint into a query and only run that explicitly (and make it work on top of |
Ah I see, I didn't realize we have all that stuff in Do we know why running ConstPropLint earlier is such a perf regression? Is it because MIR gets so much bigger? Would it help to switch the lint to a different analysis? It still does the full const-prop dance; we could possibly trade some lint power for performance here. However I think also lost track of the big picture here. The critical PR for const blocks is #112879, right? This one here is "just" some nice-to-have better alignment of check builds and full builds in terms of which diagnostics are emitted? |
same. I was sure this was a blocker, but I'm not even sure what the next one is |
… r=<try> Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on rust-lang#108730 (comment) there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
… r=cjgillot Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on rust-lang#108730 (comment) there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on rust-lang/rust#108730 (comment) there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
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.
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.
@oli-obk what's the status of this? |
#120687 did not succeed. 1.4% average regression with up to 20% regressions I don't see a way to make progress here |
Only do so after checking for previous errors as otherwise the ui test suite diff is too large.
a step towards something like #107510
This was previously only done for consts since at the time, only consts needed to run checks after borrowck or drop elab. With the move of const prop lints before optimizations, we should've switched this on for all mir bodies.
r? @ghost