-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 derefer work everwhere #96116
Make derefer work everwhere #96116
Conversation
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Oli Scherer <332036+oli-obk@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r? @oli-obk Reviewing even though I co-authored as my contribution was a mir opt test @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 5364c86 with merge 030e8caecdf11e51a4e0bbc897649f0deadcaef7... |
☀️ Try build successful - checks-actions |
Queued 030e8caecdf11e51a4e0bbc897649f0deadcaef7 with parent 8305398, future comparison URL. |
Finished benchmarking commit (030e8caecdf11e51a4e0bbc897649f0deadcaef7): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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. @bors rollup=never Footnotes |
Const eval now has more statements to chew through, so this perf change is expected. @bors r+ |
It shouldn't have, if it does, we'll deploy the appropriate fixes immediately instead of when we move this to before borrowck |
All right. I added this transmute as a testcase to Miri as well so we don't miss if/when this happens. |
However, I should note that conceptually, giving the temporary for Basically, we have to ensure that all passes that run after this just don't care about the type of a reference stored in a local -- |
It does at present. Before actually moving it earlier we were considering various strategies. While we could start messing with types and using different ones, that seems suboptimal. What we came up with in the compiler brainstorm meetings during rust all hands was more of a "mark these locals in a way that analysis passes can understand". The types are correct as far as I can tell, it's just that the locals are more temporary than regular temporaries. The extreme alternative would be to replace all such locals' types with raw pointers which will make these analyses ignore them mostly. We'll still need markers for borrowck though, even in that case |
For example, if we were to obtain such MIR as input to a formal methods tool like Prusti or Creusot, we'd definitely not want to try to treat this as a mutable reference. That would fail spectacularly. |
@bors retry Makes sense, we'll move this pass before retag and emit the correct types before doing any further actions then. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (055bf4c): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Footnotes |
All of the primary regressions and the tt-muncher secondary regressions are similar to
This looks to me like just some LLVM inliner noise. We do have more local variables now, which LLVM previously just had as intermediate LLVM Values that were rarely (if ever) put into a local. This seems to me like a problem that we could address in ways beyond fixing this PR's regression. After all, if the user writes out the temporary local variables manually instead of us expanding their code, then they would see the same issues. The other major regression in a secondary benchmark (the const eval stress test) is expected, the const evaluator has to process more statements, and every statement has overhead. Similar to the LLVM case, there are avenues to explore here to make const eval faster. I believe there are still some low hanging fruit that will yield measurable improvements, but we need to dig into benchmark dumps to find out where exactly they lie. @rustbot label: +perf-regression-triaged |
Move Derefer before Retag _Follow up work to rust-lang#96116 rust-lang#95857 #95649_ This moves `Derefer` before `Retag` and creates a new `LocalInfo` called `Temp` to avoid retagging created temp values. Zulip discussion [link](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/deref.20as.20first.20and.20only.20projection) r? `@oli-obk`
…idtwco Add validation layer for Derefer _Follow up work to rust-lang#96549 rust-lang#96116 rust-lang#95857 #95649_ This adds validation for Derefer making sure it is always the first projection. r? rust-lang/mir-opt
…twco Add validation layer for Derefer _Follow up work to rust-lang#96549 rust-lang#96116 rust-lang#95857 #95649_ This adds validation for Derefer making sure it is always the first projection. r? rust-lang/mir-opt
Pull Derefer before ElaborateDrops _Follow up work to rust-lang#97025 rust-lang#96549 rust-lang#96116 rust-lang#95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? `@oli-obk`
Pull Derefer before ElaborateDrops _Follow up work to rust-lang#97025 rust-lang#96549 rust-lang#96116 rust-lang#95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? ``@oli-obk``
Pull Derefer before ElaborateDrops _Follow up work to rust-lang#97025 rust-lang#96549 rust-lang#96116 rust-lang#95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? `@oli-obk`
Pull Derefer before ElaborateDrops _Follow up work to rust-lang#97025 rust-lang#96549 rust-lang#96116 rust-lang#95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? `@oli-obk`
Pull Derefer before ElaborateDrops _Follow up work to rust-lang#97025 rust-lang#96549 rust-lang#96116 rust-lang#95887 #95649_ This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`. r? `@oli-obk`
Follow up work on previous PR's #95649 and #95857.
r? rust-lang/mir-opt
Co-Authored-By: @oli-obk