This is a major redesign following the pattern established for the CGSCC layer to
support updates to the set of loops during the traversal of the loop nest and
to support invalidation of analyses.
An additional significant burden in the loop PM is that so many passes require
access to a large number of function analyses. Manually ensuring these are
cached, available, and preserved has been a long-standing burden in LLVM even
with the help of the automatic scheduling in the old pass manager. And it made
the new pass manager extremely unweildy. With this design, we can package the
common analyses up while in a function pass and make them immediately available
to all the loop passes. While in some cases this is unnecessary, I think the
simplicity afforded is worth it.
This does not (yet) address loop simplified form or LCSSA form, but those are
the next things on my radar and I have a clear plan for them.
While the patch is very large, most of it is either mechanically updating loop
passes to the new API or the new testing for the loop PM. The code for it is
reasonably compact.
I have not yet updated all of the loop passes to correctly leverage the update
mechanisms demonstrated in the unittests. I'll do that in follow-up patches
along with improved FileCheck tests for those passes that ensure things work in
more realistic scenarios. In many cases, there isn't much we can do with these
until the loop simplified form and LCSSA form are in place.
The unittests are somewhat a placeholder. I wrote them using gmock because it
was substantially easier to make progress and as a demonstration of the
improvements that the gmock infrsatructure can bring to writing precise and
clear test passes to plug into the pass manager. I'm starting an llvm-dev
discussion about whether this is enough to convince folks that we should start
leveraging gmock within LLVM. If we don't go that route, I'll rewrite the tests
without gmock (but likely lose some precision and coverage in the process).
Nit, "function"?