Skip to content

[NLL] integrate liveness with inference #45186

Closed
@nikomatsakis

Description

@nikomatsakis

Once #44904 is fixed, the next step is to start adding constraints. I think that the liveness constraints are the easiest to add. These come in two forms. The first part are the constraints that are due to active uses, and the other are constraints due to drops.

The basic idea is this:

  • If at some point P a value V may be used again (excluding future drops):
    • Then all lifetimes appearing in the type of V must be live at P.
  • If at some point P a value V may be dropped:
    • Then all lifetimes appearing in the type of V which are not marked as may-dangle must be live at P.

That said, I think that, for this first issue, we should basically just ignore the special case of drop. In fact, we are going to want to make a few further refinements as discussed here -- in particular extending this code to consider not only liveness, but also which values are initialized. Let's ignore all of that for now and just get the basics up and going.

As it happens, we have some existing code for computing which values are live, located here. Unfortunately, it has some limitations:

I'm not sure if we want to take precisely the same approach with the liveness code or not. It's a convenient setup, in any case, since we can then re-use this same "simulate" code to compute the fixed-point and -- after the fixed-point is computed -- to find the live bits at any particular point within the basic block.

Anyway, I have to run now, so I'll try to write up more mentoring notes later on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions