Skip to content

Visiting a MIR return should visit the return place too #72032

Closed
@jonas-schievink

Description

@jonas-schievink

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 a return, 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 within super_terminator_kind has the problem that the MutVisitor receives a &mut Local, but the local return 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-mir-optArea: MIR optimizationsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions