Skip to content

Maybe emit phis directly instead of using alloca #11008

Closed
@o11c

Description

@o11c

It might be better to generate phis instead of emitting allocas and letting LLVM do the work in the (I think) SRoA optimization pass.

An example of what could be done (in C, without the case of taking the address of the local) is at https://gist.github.com/o11c/7995342

The general approach is:
For each block, create a phi node for each live variable.
For each jump to a block, add an alternative on the phi with the value before that jump.

Unlike C++, Rust can afford to do this in the general case because moves are always free. However, it is still complicated by the fact that there may be references to the variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions