Description
In #41625, the role of the MIR pass manager has been significantly scaled back. Once can still register passes, but they always take an &mut Mir
, and the set of passes is defined in driver
and cannot be readily changed (in particular, the session no longer has a Passes
struct). @eddyb would like to go further, I think, and remove the Passes
strruct from the tcx
altogether -- the main reason it is still there is that it allows the MIR code to (indirectly) invoke passes defined in other crates, e.g. elaborate_drops
. I tend to also think it's nice to "collect" the MIR passes into one single data-structure to ensure that (e.g.) we have the option to dump the MIR in between each pass and apply other debugging conventions (as well as to easily reorder passes or introduce new ones).
Longer term, what do we think this should look like? One extreme future might remove the Passes
struct altogether and have the invocations of each pass kind of hard-coded -- we could build up the set of Pass
objects in the various "mir queries", for example. Another extreme would be to make the Passes
struct more complex to support plugins adding custom optimizations -- it seems like we're a long way from there, and that may never make sense.
To do the "radically scaled back" version of futures, we'd have to at least consolidate the borrowck and mir crates, or make one a dependency of the other, or something like that.
cc @rust-lang/compiler -- thoughts?