emit Retag for compound types with reference fields#98625
Merged
bors merged 1 commit intorust-lang:masterfrom Jun 29, 2022
Merged
emit Retag for compound types with reference fields#98625bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
Some changes occurred to MIR optimizations cc @rust-lang/mir-opt |
oli-obk
reviewed
Jun 28, 2022
| ty::Array(..) | ty::Slice(..) | ty::Tuple(..) | ty::Adt(..) => false, | ||
| // Compound types: recurse | ||
| ty::Array(ty, _) | ty::Slice(ty) => { | ||
| // This does not branch so we keep the depth the same. |
Contributor
There was a problem hiding this comment.
I don't understand the reasoning behind this. I can now ICE miri by syntactically nesting 10000 arrays, why is branching out relevant?
Member
Author
There was a problem hiding this comment.
This is meant to guard against time complexity, not stack overflows. Branching is a lot more expensive, if every level has N>1 fields then it is exponential in the depth, whereas array/slice checking is linear in the depth.
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit 5fc1dd1 has been approved by |
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Jun 29, 2022
emit Retag for compound types with reference fields I want to add an option to Miri to do retagging inside reference fields. But that means we first have to even emit `Retag` for types that *contain* references (rather than being of reference types). :) Stacked Borrows originally did that, but we stopped doing it when hitting bunch of issues in the standard library. However I have since realized that we actually do emit `noalias` for newtypes references, which means for soundness we should recurse into fields. Also it'd probably be bad news if newtypes lose out on optimizations (and they don't, for anything else). I want to add an option for that to Miri so that we can start experimenting with those semantics. r? `@oli-obk`
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 29, 2022
Rollup of 7 pull requests Successful merges: - rust-lang#98415 (Migrate some `rustc_borrowck` diagnostics to `SessionDiagnostic`) - rust-lang#98479 (Add `fetch_not` method on `AtomicBool`) - rust-lang#98499 (Erase regions in New Abstract Consts) - rust-lang#98516 (library: fix uefi va_list type definition) - rust-lang#98554 (Fix box with custom allocator in miri) - rust-lang#98607 (Clean up arg mismatch diagnostic, generalize tuple wrap suggestion) - rust-lang#98625 (emit Retag for compound types with reference fields) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I want to add an option to Miri to do retagging inside reference fields. But that means we first have to even emit
Retagfor types that contain references (rather than being of reference types). :)Stacked Borrows originally did that, but we stopped doing it when hitting bunch of issues in the standard library. However I have since realized that we actually do emit
noaliasfor newtypes references, which means for soundness we should recurse into fields. Also it'd probably be bad news if newtypes lose out on optimizations (and they don't, for anything else). I want to add an option for that to Miri so that we can start experimenting with those semantics.r? @oli-obk