[PATCH] D28292: [PM] Rewrite the loop pass manager to use a worklist and augmented run arguments much like the CGSCC pass manager.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 06:06:30 PST 2017


chandlerc created this revision.
chandlerc added reviewers: jlebar, bogner.
chandlerc added a subscriber: llvm-commits.
Herald added subscribers: mzolotukhin, mcrosier, mehdi_amini, sanjoy.

This is a major redesign following the pattern establish 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).


https://reviews.llvm.org/D28292

Files:
  include/llvm/Analysis/IVUsers.h
  include/llvm/Analysis/LoopAccessAnalysis.h
  include/llvm/Analysis/LoopInfo.h
  include/llvm/Analysis/LoopPassManager.h
  include/llvm/Transforms/Scalar/IndVarSimplify.h
  include/llvm/Transforms/Scalar/LICM.h
  include/llvm/Transforms/Scalar/LoopDeletion.h
  include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
  include/llvm/Transforms/Scalar/LoopInstSimplify.h
  include/llvm/Transforms/Scalar/LoopRotation.h
  include/llvm/Transforms/Scalar/LoopSimplifyCFG.h
  include/llvm/Transforms/Scalar/LoopStrengthReduce.h
  include/llvm/Transforms/Scalar/LoopUnrollPass.h
  lib/Analysis/IVUsers.cpp
  lib/Analysis/LoopAccessAnalysis.cpp
  lib/Analysis/LoopInfo.cpp
  lib/Analysis/LoopPass.cpp
  lib/Analysis/LoopPassManager.cpp
  lib/Passes/PassBuilder.cpp
  lib/Transforms/Scalar/IndVarSimplify.cpp
  lib/Transforms/Scalar/LICM.cpp
  lib/Transforms/Scalar/LoopDeletion.cpp
  lib/Transforms/Scalar/LoopDistribute.cpp
  lib/Transforms/Scalar/LoopIdiomRecognize.cpp
  lib/Transforms/Scalar/LoopInstSimplify.cpp
  lib/Transforms/Scalar/LoopRotation.cpp
  lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  lib/Transforms/Scalar/LoopStrengthReduce.cpp
  lib/Transforms/Scalar/LoopUnrollPass.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Other/loop-pass-ordering.ll
  test/Other/new-pass-manager.ll
  test/Other/pass-pipeline-parsing.ll
  unittests/Analysis/LoopPassManagerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28292.83044.patch
Type: text/x-patch
Size: 131833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170104/138816d6/attachment-0001.bin>


More information about the llvm-commits mailing list