[PATCH] D61471: [MemorySSA] Refactor removing multiple trivial phis [NFC].

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 16:11:24 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL359842: [MemorySSA] Refactor removing multiple trivial phis [NFC]. (authored by asbirlea, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61471/new/

https://reviews.llvm.org/D61471

Files:
  llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
  llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp


Index: llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
+++ llvm/trunk/include/llvm/Analysis/MemorySSAUpdater.h
@@ -261,6 +261,7 @@
   MemoryAccess *recursePhi(MemoryAccess *Phi);
   template <class RangeType>
   MemoryAccess *tryRemoveTrivialPhi(MemoryPhi *Phi, RangeType &Operands);
+  void tryRemoveTrivialPhis(ArrayRef<WeakVH> UpdatedPHIs);
   void fixupDefs(const SmallVectorImpl<WeakVH> &);
   // Clone all uses and defs from BB to NewBB given a 1:1 map of all
   // instructions and blocks cloned, and a map of MemoryPhi : Definition
Index: llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
===================================================================
--- llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
+++ llvm/trunk/lib/Analysis/MemorySSAUpdater.cpp
@@ -355,12 +355,9 @@
   }
 
   // Optimize potentially non-minimal phis added in this method.
-  for (unsigned Idx = NewPhiIndex; Idx < NewPhiIndexEnd; ++Idx) {
-    if (auto *MPhi = cast_or_null<MemoryPhi>(InsertedPHIs[Idx])) {
-      auto OperRange = MPhi->operands();
-      tryRemoveTrivialPhi(MPhi, OperRange);
-    }
-  }
+  unsigned NewPhiSize = NewPhiIndexEnd - NewPhiIndex;
+  if (NewPhiSize)
+    tryRemoveTrivialPhis(ArrayRef<WeakVH>(&InsertedPHIs[NewPhiIndex], NewPhiSize));
 
   // Now that all fixups are done, rename all uses if we are asked.
   if (RenameUses) {
@@ -1215,6 +1212,14 @@
   }
 }
 
+void MemorySSAUpdater::tryRemoveTrivialPhis(ArrayRef<WeakVH> UpdatedPHIs) {
+  for (auto &VH : UpdatedPHIs)
+    if (auto *MPhi = cast_or_null<MemoryPhi>(VH)) {
+      auto OperRange = MPhi->operands();
+      tryRemoveTrivialPhi(MPhi, OperRange);
+    }
+}
+
 MemoryAccess *MemorySSAUpdater::createMemoryAccessInBB(
     Instruction *I, MemoryAccess *Definition, const BasicBlock *BB,
     MemorySSA::InsertionPlace Point) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61471.197888.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190502/f7aafec6/attachment.bin>


More information about the llvm-commits mailing list