From: Alina Sbirlea Date: Thu, 31 Jan 2019 21:12:41 +0000 (+0000) Subject: [EarlyCSE & MSSA] Cleanup special handling for removing MemoryAccesses. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b480414e1d0c8e00cca8f3e52321add513039e07;p=llvm [EarlyCSE & MSSA] Cleanup special handling for removing MemoryAccesses. Summary: Moving special handling to MemorySSAUpdater in D57199. Reviewers: gberry, george.burgess.iv Subscribers: sanjoy, jlebar, Prazek, llvm-commits Differential Revision: https://reviews.llvm.org/D57200 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352794 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp index ad60aac4585..bec84ae1057 100644 --- a/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/lib/Transforms/Scalar/EarlyCSE.cpp @@ -607,36 +607,11 @@ private: MSSA->verifyMemorySSA(); // Removing a store here can leave MemorySSA in an unoptimized state by // creating MemoryPhis that have identical arguments and by creating - // MemoryUses whose defining access is not an actual clobber. We handle the - // phi case eagerly here. The non-optimized MemoryUse case is lazily - // updated by MemorySSA getClobberingMemoryAccess. - if (MemoryAccess *MA = MSSA->getMemoryAccess(Inst)) { - // Optimize MemoryPhi nodes that may become redundant by having all the - // same input values once MA is removed. - SmallSetVector PhisToCheck; - SmallVector WorkQueue; - WorkQueue.push_back(MA); - // Process MemoryPhi nodes in FIFO order using a ever-growing vector since - // we shouldn't be processing that many phis and this will avoid an - // allocation in almost all cases. - for (unsigned I = 0; I < WorkQueue.size(); ++I) { - MemoryAccess *WI = WorkQueue[I]; - - for (auto *U : WI->users()) - if (MemoryPhi *MP = dyn_cast(U)) - PhisToCheck.insert(MP); - - MSSAUpdater->removeMemoryAccess(WI); - - for (MemoryPhi *MP : PhisToCheck) { - MemoryAccess *FirstIn = MP->getIncomingValue(0); - if (llvm::all_of(MP->incoming_values(), - [=](Use &In) { return In == FirstIn; })) - WorkQueue.push_back(MP); - } - PhisToCheck.clear(); - } - } + // MemoryUses whose defining access is not an actual clobber. The phi case + // is handled by MemorySSA when passing OptimizePhis = true to + // removeMemoryAccess. The non-optimized MemoryUse case is lazily updated + // by MemorySSA's getClobberingMemoryAccess. + MSSAUpdater->removeMemoryAccess(Inst, true); } };