From b4559a2179bf64fa38b2cccf91b067cc6fcc8e9d Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 13 Jul 2007 23:57:11 +0000 Subject: Make LCSSA a loop pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39844 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LCSSA.cpp | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'lib/Transforms/Utils') diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index ed166644d7..3f4bad5c51 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -36,7 +36,8 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/Dominators.h" -#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" #include @@ -46,17 +47,17 @@ using namespace llvm; STATISTIC(NumLCSSA, "Number of live out of a loop variables"); namespace { - struct VISIBILITY_HIDDEN LCSSA : public FunctionPass { + struct VISIBILITY_HIDDEN LCSSA : public LoopPass { static char ID; // Pass identification, replacement for typeid - LCSSA() : FunctionPass((intptr_t)&ID) {} + LCSSA() : LoopPass((intptr_t)&ID) {} // Cached analysis information for the current function. LoopInfo *LI; DominatorTree *DT; std::vector LoopBlocks; - virtual bool runOnFunction(Function &F); - bool visitSubloop(Loop* L); + virtual bool runOnLoop(Loop *L, LPPassManager &LPM); + void ProcessInstruction(Instruction* Instr, const std::vector& exitBlocks); @@ -69,7 +70,9 @@ namespace { AU.addRequiredID(LoopSimplifyID); AU.addPreservedID(LoopSimplifyID); AU.addRequired(); + AU.addPreserved(); AU.addRequired(); + AU.addPreserved(); } private: void getLoopValuesUsedOutsideLoop(Loop *L, @@ -88,28 +91,15 @@ namespace { RegisterPass X("lcssa", "Loop-Closed SSA Form Pass"); } -FunctionPass *llvm::createLCSSAPass() { return new LCSSA(); } +LoopPass *llvm::createLCSSAPass() { return new LCSSA(); } const PassInfo *llvm::LCSSAID = X.getPassInfo(); /// runOnFunction - Process all loops in the function, inner-most out. -bool LCSSA::runOnFunction(Function &F) { - bool changed = false; +bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) { - LI = &getAnalysis(); + LI = &LPM.getAnalysis(); DT = &getAnalysis(); - for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) - changed |= visitSubloop(*I); - - return changed; -} - -/// visitSubloop - Recursively process all subloops, and then process the given -/// loop if it has live-out values. -bool LCSSA::visitSubloop(Loop* L) { - for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) - visitSubloop(*I); - // Speed up queries by creating a sorted list of blocks LoopBlocks.clear(); LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end()); -- cgit v1.2.3-70-g09d2