-
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
mir opt + codegen: handle subtyping #112307
Conversation
r? @jackh726 (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.
⌛ Trying commit b47112e337af38985998a9c2cb8b0663da9bfdee with merge 688ecdd88c9c98c0dd3ed5f53d5180535c63086b... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (688ecdd88c9c98c0dd3ed5f53d5180535c63086b): comparison URL. Overall result: ❌ regressions - no 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. @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: 646.615s -> 645.351s (-0.20%) |
This comment has been minimized.
This comment has been minimized.
29ef7e2
to
a4fc594
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit a4fc594dfeaa7cee6b4aa2769ab282b183a7eaf7 with merge 26bd1b92367a2173690199389c3e1e44a1ce759b... |
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
yeah, agree with that 👍 we should add a mir pass post analysis which makes subtyping explicit, opened #112651 for that. I don't have the capacity to actually implement this though, so I would like for someone else to take that over. I would still like to merge this PR (putting a does this seem sensible to you @cjgillot? |
I agree to do it that way. |
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.
Everything looks good.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (bb95b7d): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 662.939s -> 662s (-0.14%) |
Remove assert that checks type equality rust-lang#112307 although this prevented `unsound` issues it also seems to introduce regressions rust-lang#114858 is example of this regression. I locally tested this rust-lang#114858 (comment) issue and failing assert is [this](https://www.diffchecker.com/cjb7jSQm/). This is also related to rust-lang#115025
Remove assert that checks type equality rust-lang/rust#112307 although this prevented `unsound` issues it also seems to introduce regressions rust-lang/rust#114858 is example of this regression. I locally tested this rust-lang/rust#114858 (comment) issue and failing assert is [this](https://www.diffchecker.com/cjb7jSQm/). This is also related to rust-lang/rust#115025
op.layout.ty = local_ty; | ||
} | ||
} | ||
}; |
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.
FWIW in the MIR interpreter we avoid the risk of this by not having the type of the local in our locals
map to begin with: we store a IndexVec<mir::Local, LocalState<'tcx, Prov>>
, where LocalState
is basically just interpret::Operand
. When we need the type we always go through body.local_decls
.
So that might also be something codegen can do; storing the type in self.locals
is redundant.
…fleLapkin explain a good reason for why LocalValue does not store the type of the local As found out by `@lcnr` in rust-lang#112307, storing the type here can lead to subtle bugs when it gets out of sync with the MIR body. That's not the reason why the interpreter does it this way I think, but good thing we dodged that bullet. :)
explain a good reason for why LocalValue does not store the type of the local As found out by `@lcnr` in rust-lang/rust#112307, storing the type here can lead to subtle bugs when it gets out of sync with the MIR body. That's not the reason why the interpreter does it this way I think, but good thing we dodged that bullet. :)
fixes #107205
the same issue was caused in multiple places:
I changed codegen to always update the type in the operands used for locals which should guard against any new occurrences of this bug going forward. I don't know how to make mir optimizations more resilient here. Hopefully the added tests will be enough to detect any trivially wrong optimizations going forward.