-
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
MIR InstCombine introduces copies of mutable borrows #46420
Comments
&mut String
Is the solution to change |
@oli-obk You really don't want move semantics. I think copying is correct at those lower levels, even if the type doesn't implement |
I personally consider this at least potentially OK. My view has been that 'the thing we call MIR' is really at least two IRs -- maybe more! -- that are represented using one set of data structures, with different invariants: When first constructed, we have MIR proper. Then, after drop elaboration has completed, we have a lower-level IR. Plausibly, in this IR, the aliasing rules are weaker. That said, we may want to keep the stricter rules, so that we can optimize more on that basis! Regardless of all of that, it would be great to document the assumptions at each point (e.g., in the rustc-guide). |
This is now also fixed by #72820, which removed this fold in InstCombine |
https://play.rust-lang.org/?gist=9f782298cc5b0f6cd557baef9e443096&version=nightly
generates the following MIR:
Which -- though we don't run it again after optimizations -- wouldn't pass
TypeckMir
since it's a copy of a&mut String
.That came from InstCombine on the following
This may or may not be a problem, but I wanted to file it in case it impacts any of the assumptions desired from the Copy/Move split on Operand.
Edit: I suppose this instcombine has long potentially changed the type of the operand, since it doesn't check mutability of the outer
&
or the borrow being*
d.cc @eddyb
The text was updated successfully, but these errors were encountered: