llvm.org GIT mirror llvm / fa0da85
[MemorySSA] Refactor removing multiple trivial phis [NFC]. Summary: Create a method to clean up multiple potentially trivial phis, since we will need this often. Reviewers: george.burgess.iv Subscribers: jlebar, Prazek, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61471 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359842 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 1 year, 5 months ago
2 changed file(s) with 12 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
260260 MemoryAccess *recursePhi(MemoryAccess *Phi);
261261 template
262262 MemoryAccess *tryRemoveTrivialPhi(MemoryPhi *Phi, RangeType &Operands);
263 void tryRemoveTrivialPhis(ArrayRef UpdatedPHIs);
263264 void fixupDefs(const SmallVectorImpl &);
264265 // Clone all uses and defs from BB to NewBB given a 1:1 map of all
265266 // instructions and blocks cloned, and a map of MemoryPhi : Definition
354354 }
355355
356356 // Optimize potentially non-minimal phis added in this method.
357 for (unsigned Idx = NewPhiIndex; Idx < NewPhiIndexEnd; ++Idx) {
358 if (auto *MPhi = cast_or_null(InsertedPHIs[Idx])) {
359 auto OperRange = MPhi->operands();
360 tryRemoveTrivialPhi(MPhi, OperRange);
361 }
362 }
357 unsigned NewPhiSize = NewPhiIndexEnd - NewPhiIndex;
358 if (NewPhiSize)
359 tryRemoveTrivialPhis(ArrayRef(&InsertedPHIs[NewPhiIndex], NewPhiSize));
363360
364361 // Now that all fixups are done, rename all uses if we are asked.
365362 if (RenameUses) {
12141211 }
12151212 }
12161213
1214 void MemorySSAUpdater::tryRemoveTrivialPhis(ArrayRef UpdatedPHIs) {
1215 for (auto &VH : UpdatedPHIs)
1216 if (auto *MPhi = cast_or_null(VH)) {
1217 auto OperRange = MPhi->operands();
1218 tryRemoveTrivialPhi(MPhi, OperRange);
1219 }
1220 }
1221
12171222 MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB(
12181223 Instruction *I, MemoryAccess *Definition, const BasicBlock *BB,
12191224 MemorySSA::InsertionPlace Point) {