-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Visiting a MIR return should visit the return place too #72032
Copy link
Copy link
Closed
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-mir-optArea: MIR optimizationsArea: MIR optimizationsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-mir-optArea: MIR optimizationsArea: MIR optimizationsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The
returnterminator 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,MaybeLiveLocalsreports that_0is dead before areturn, which is wrong (it must always be live there). These don't currently cause any harm, since use of_0is fairly limited, but they are an issue for destination propagation / NRVO, which can propagate_0to arbitrary places in the function and needs to have correct information to do so soundly.The simple fix of calling
visit_localfrom withinsuper_terminator_kindhas the problem that theMutVisitorreceives a&mut Local, but the localreturnreads 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