From: Chandler Carruth Date: Sun, 11 Aug 2013 01:03:18 +0000 (+0000) Subject: Reformat some bits of AllocaPromoter and simplify the name and type of X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3c7a446059133de68c912242cb3b0cc934b8e6b1;p=oota-llvm.git Reformat some bits of AllocaPromoter and simplify the name and type of our visiting datastructures in the AllocaPromoter/SSAUpdater path of SROA. Also shift the order if clears around to be more consistent. No functionality changed here, this is just a cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188144 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 5c55143a9b1..27938251376 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -733,9 +733,9 @@ class AllocaPromoter : public LoadAndStorePromoter { SmallVector DVIs; public: - AllocaPromoter(const SmallVectorImpl &Insts, SSAUpdater &S, + AllocaPromoter(const SmallVectorImpl &Insts, SSAUpdater &S, AllocaInst &AI, DIBuilder &DIB) - : LoadAndStorePromoter(Insts, S), AI(AI), DIB(DIB) {} + : LoadAndStorePromoter(Insts, S), AI(AI), DIB(DIB) {} void run(const SmallVectorImpl &Insts) { // Retain the debug information attached to the alloca for use when @@ -3364,12 +3364,12 @@ void SROA::deleteDeadInstructions(SmallPtrSet &DeletedAllocas) { } static void enqueueUsersInWorklist(Instruction &I, - SmallVectorImpl &UseWorklist, - SmallPtrSet &VisitedUses) { + SmallVectorImpl &Worklist, + SmallPtrSet &Visited) { for (Value::use_iterator UI = I.use_begin(), UE = I.use_end(); UI != UE; ++UI) - if (VisitedUses.insert(&UI.getUse())) - UseWorklist.push_back(&UI.getUse()); + if (Visited.insert(cast(*UI))) + Worklist.push_back(cast(*UI)); } /// \brief Promote the allocas, using the best available technique. @@ -3396,29 +3396,29 @@ bool SROA::promoteAllocas(Function &F) { DEBUG(dbgs() << "Promoting allocas with SSAUpdater...\n"); SSAUpdater SSA; DIBuilder DIB(*F.getParent()); - SmallVector Insts; + SmallVector Insts; // We need a worklist to walk the uses of each alloca. - SmallVector UseWorklist; - SmallPtrSet VisitedUses; + SmallVector Worklist; + SmallPtrSet Visited; SmallVector DeadInsts; for (unsigned Idx = 0, Size = PromotableAllocas.size(); Idx != Size; ++Idx) { AllocaInst *AI = PromotableAllocas[Idx]; - UseWorklist.clear(); - VisitedUses.clear(); + Insts.clear(); + Worklist.clear(); + Visited.clear(); - enqueueUsersInWorklist(*AI, UseWorklist, VisitedUses); + enqueueUsersInWorklist(*AI, Worklist, Visited); - while (!UseWorklist.empty()) { - Use *U = UseWorklist.pop_back_val(); - Instruction &I = *cast(U->getUser()); + while (!Worklist.empty()) { + Instruction *I = Worklist.pop_back_val(); // FIXME: Currently the SSAUpdater infrastructure doesn't reason about // lifetime intrinsics and so we strip them (and the bitcasts+GEPs // leading to them) here. Eventually it should use them to optimize the // scalar values produced. - if (IntrinsicInst *II = dyn_cast(&I)) { + if (IntrinsicInst *II = dyn_cast(I)) { assert(II->getIntrinsicID() == Intrinsic::lifetime_start || II->getIntrinsicID() == Intrinsic::lifetime_end); II->eraseFromParent(); @@ -3428,12 +3428,12 @@ bool SROA::promoteAllocas(Function &F) { // Push the loads and stores we find onto the list. SROA will already // have validated that all loads and stores are viable candidates for // promotion. - if (LoadInst *LI = dyn_cast(&I)) { + if (LoadInst *LI = dyn_cast(I)) { assert(LI->getType() == AI->getAllocatedType()); Insts.push_back(LI); continue; } - if (StoreInst *SI = dyn_cast(&I)) { + if (StoreInst *SI = dyn_cast(I)) { assert(SI->getValueOperand()->getType() == AI->getAllocatedType()); Insts.push_back(SI); continue; @@ -3442,11 +3442,10 @@ bool SROA::promoteAllocas(Function &F) { // For everything else, we know that only no-op bitcasts and GEPs will // make it this far, just recurse through them and recall them for later // removal. - DeadInsts.push_back(&I); - enqueueUsersInWorklist(I, UseWorklist, VisitedUses); + DeadInsts.push_back(I); + enqueueUsersInWorklist(*I, Worklist, Visited); } AllocaPromoter(Insts, SSA, *AI, DIB).run(Insts); - Insts.clear(); while (!DeadInsts.empty()) DeadInsts.pop_back_val()->eraseFromParent(); AI->eraseFromParent();