Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incr. comp.: Clarify story around MIR dependency tracking #34765

Closed
michaelwoerister opened this issue Jul 11, 2016 · 4 comments
Closed

incr. comp.: Clarify story around MIR dependency tracking #34765

michaelwoerister opened this issue Jul 11, 2016 · 4 comments
Labels
A-incr-comp Area: Incremental compilation

Comments

@michaelwoerister
Copy link
Member

At the moment, dependency tracking around MIR related things is not implemented completely. In particular:

  • We generate various MIR-related dependency nodes (MirMapConstruction, MirPass, MirTypeck) but we don't seem to register any reads to these nodes later on: The MirMap allows for accessing MIR with the dependency tracking system knowing about it.
  • There doesn't seem to be a reason why MirTypeck is its own kind of dependency node while all other passes use the MirPass node.
  • There is no clear dependency node for registering read edges to after MIR has been fully constructed. MirMapConstruction more or less tracks dependencies of constructing MIR before any transformations are done on it. Reusing it for registering reads to the final MIR would be possible, but would lead to a strange tangle of circular dependencies between MirMapConstruction, MirTypeck, and MirPass nodes. It would not be wrong but it would be messy.

I suggest that we either just have one kind of MIR dependency node that subsumes MIR construction and all transformations on it, or that we have a more accurate representation of dependencies where each kind of MIR pass has its own kind of dependency node and then there is a FinalMir node, that represents the MIR in its final state.

@michaelwoerister michaelwoerister added the A-incr-comp Area: Incremental compilation label Jul 11, 2016
@michaelwoerister
Copy link
Member Author

cc @nikomatsakis

@nikomatsakis nikomatsakis added this to the Incremental compilation alpha milestone Jul 23, 2016
@nikomatsakis
Copy link
Contributor

Yeah, this seems bad. I've also been thinking a bit about how to go about saving/restoring MIR -- as the .o re-use stuff gets close to completion, and MIR-trans is landing, this is going to be the Next Big Step to save a lot of compilation time.

The most straight-forward thing would be to model the MIR passes the way we model everything else:

  • MirMap(DefId) -- tracks the MIR that we created for a given def-id.
  • one DepNode variant per MIR pass, so e.g. MirConstruction, MirSimplify, MirElaborate, etc.

This seems like the most straightforward thing to do. But I think it's probably more data than we need. I think we could collapse all the passes into one with no loss of fidelity. For that matter, we could probably just remove the dep-node for the pass and just use a single dep-node (Mir) for both the mir itself and passes that construct and transform the MIR. That would seem to match your "simple" suggestion. I think we should go for that -- but view it as an "optimization" on the canonical model.

Generalizing somewhat, if the purpose of a pass is just to produce a single particular data-structure, then distinguishing MirBuild(DefId) from Mir(DefId) doesn't seem to buy us anything.

But if we have a single pass that may generate a lot of data-structures, I think it makes more sense, particularly if those data structures can be changed from other places (otherwise, you can lose precision in the graph).

@michaelwoerister
Copy link
Member Author

Is there any case you foresee where it would make sense to have more than one DepNode? As long as each pass just produces a transformed version of a function's MIR, the simple approach should be fine, I think.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Aug 9, 2016
Per the discussion on rust-lang#34765, we make one `DepNode::Mir` variant and use
it to represent both the MIR tracking map as well as passes that operate
on MIR. We also track loads of cached MIR (which naturally comes from
metadata).

Note that the "HAIR" pass adds a read of TypeckItemBody because it uses
a myriad of tables that are not individually tracked.
@nikomatsakis
Copy link
Contributor

This was fixed by #35166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation
Projects
None yet
Development

No branches or pull requests

2 participants