Index: lib/Analysis/MemorySSAUpdater.cpp =================================================================== --- lib/Analysis/MemorySSAUpdater.cpp +++ lib/Analysis/MemorySSAUpdater.cpp @@ -490,8 +490,8 @@ void MemorySSAUpdater::removeEdge(BasicBlock *From, BasicBlock *To) { if (MemoryPhi *MPhi = MSSA->getMemoryAccess(To)) { MPhi->unorderedDeleteIncomingBlock(From); - if (MPhi->getNumIncomingValues() == 1) - removeMemoryAccess(MPhi); + auto OperRange = MPhi->operands(); + tryRemoveTrivialPhi(MPhi, OperRange); } } @@ -507,8 +507,8 @@ Found = true; return false; }); - if (MPhi->getNumIncomingValues() == 1) - removeMemoryAccess(MPhi); + auto OperRange = MPhi->operands(); + tryRemoveTrivialPhi(MPhi, OperRange); } } @@ -617,8 +617,8 @@ // If NewMPhi is a trivial phi, remove it. Its use in the header MPhi will be // replaced with the unique value. - if (HasUniqueIncomingValue) - removeMemoryAccess(NewMPhi); + auto OperRange = MPhi->operands(); + tryRemoveTrivialPhi(MPhi, OperRange); } void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks, @@ -1227,8 +1227,8 @@ return false; }); Phi->addIncoming(NewPhi, New); - if (onlySingleValue(NewPhi)) - removeMemoryAccess(NewPhi); + auto OperRange = NewPhi->operands(); + tryRemoveTrivialPhi(NewPhi, OperRange); } } @@ -1310,8 +1310,8 @@ if (!DeadBlocks.count(Succ)) if (MemoryPhi *MP = MSSA->getMemoryAccess(Succ)) { MP->unorderedDeleteIncomingBlock(BB); - if (MP->getNumIncomingValues() == 1) - removeMemoryAccess(MP); + auto OperRange = MP->operands(); + tryRemoveTrivialPhi(MP, OperRange); } // Drop all references of all accesses in BB if (MemorySSA::AccessList *Acc = MSSA->getWritableBlockAccesses(BB))