Skip to content
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

emit Retag for compound types with reference fields #98625

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

RalfJung
Copy link
Member

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

@rustbot
Copy link
Collaborator

rustbot commented Jun 28, 2022

Some changes occurred to MIR optimizations

cc @rust-lang/mir-opt

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 28, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reasoning behind this. I can now ICE miri by syntactically nesting 10000 arrays, why is branching out relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 28, 2022

📌 Commit 5fc1dd1 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2022
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
@bors bors merged commit 68228be into rust-lang:master Jun 29, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 29, 2022
@RalfJung RalfJung deleted the retag branch June 30, 2022 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants