Visiting a MIR return
should visit the return place too
#72032
Labels
A-MIR
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
A-mir-opt
Area: MIR optimizations
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The
return
terminator conceptually moves out of the return place_0
, but this is not currently reflected by the visitor infrastructure.This can lead to incorrect dataflow solutions for
_0
. For example,MaybeLiveLocals
reports that_0
is dead before areturn
, which is wrong (it must always be live there). These don't currently cause any harm, since use of_0
is fairly limited, but they are an issue for destination propagation / NRVO, which can propagate_0
to arbitrary places in the function and needs to have correct information to do so soundly.The simple fix of calling
visit_local
from withinsuper_terminator_kind
has the problem that theMutVisitor
receives a&mut Local
, but the localreturn
reads from can not be changed. This can be caught with an assertion, but maybe there is a better solution for this?cc @rust-lang/wg-mir-opt
The text was updated successfully, but these errors were encountered: