From cd96cfd8df1df870b6a765d05f1058070188f77f Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sat, 9 Jul 2016 03:03:01 +0000 Subject: [PM] Port LoopSimplify to the new pass manager. While here move simplifyLoop() function to the new header, as suggested by Chandler in the review. Differential Revision: http://reviews.llvm.org/D21404 llvm-svn: 274959 --- llvm/lib/Transforms/Utils/LoopSimplify.cpp | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp') diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 66aef29ea24..a364cab5062 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -37,6 +37,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Transforms/Utils/LoopSimplify.h" #include "llvm/Transforms/Scalar.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SetOperations.h" @@ -802,6 +803,36 @@ bool LoopSimplify::runOnFunction(Function &F) { return Changed; } +PreservedAnalyses LoopSimplifyPass::run(Function &F, + AnalysisManager &AM) { + bool Changed = false; + LoopInfo *LI = &AM.getResult(F); + DominatorTree *DT = &AM.getResult(F); + ScalarEvolution *SE = AM.getCachedResult(F); + AssumptionCache *AC = &AM.getResult(F); + + // FIXME: This pass should verify that the loops on which it's operating + // are in canonical SSA form, and that the pass itself preserves this form. + for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) + Changed |= simplifyLoop(*I, DT, LI, SE, AC, true /* PreserveLCSSA */); + + if (!Changed) + return PreservedAnalyses::all(); + PreservedAnalyses PA; + + // The old PM also preserved LCSSAID and BreakCriticalEdgesID. + // This makes no sense in the new PM so we omit those from the set + // of preserved passes. + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + PA.preserve(); + return PA; +} + // FIXME: Restore this code when we re-enable verification in verifyAnalysis // below. #if 0 -- cgit v1.2.3