Skip to content

Refactor non_ssa_locals to remove LocalAnalyzer::process_place #72931

Open
@ecstatic-morse

Description

@ecstatic-morse

While doing an initial implementation of rust-lang/compiler-team#300, I began replacing all uses of {Non,}MutatingUseContext::Projection. One user was rustc_codegen_ssa::mir::analyze::LocalAnalyzer, which is doing a custom recursive traversal in process_place. There's a HACK comment from @eddyb suggesting that this should be rewritten.

@eddyb, did you have something specific in mind? I spent some time trying to decipher the logic here, but there's parts I don't understand. For example, there's a long comment about why we need to call visit_local for NonUseContext::VarDebugInfo, but visit_local does nothing for NonUses. What's the indended behavior here?

Additionally, LocalAnalyzer visits basic blocks in numerical order, but this code assumes we will visit the assignment to a local before any uses of it. This isn't a soundness issue; The worst thing that can happen is that locals are placed onto the stack unnecessarily. However, I think we should be visiting basic blocks in RPO, no?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-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