[PATCH] D48081: [VPlanRecipeBase] Add eraseFromParent().

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 18 08:23:23 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334951: [VPlanRecipeBase] Add eraseFromParent(). (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48081?vs=150950&id=151719#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48081

Files:
  llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
  llvm/trunk/lib/Transforms/Vectorize/VPlan.h
  llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp


Index: llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
+++ llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
@@ -225,6 +225,10 @@
   Parent->getRecipeList().insert(InsertPos->getIterator(), this);
 }
 
+iplist<VPRecipeBase>::iterator VPRecipeBase::eraseFromParent() {
+  return getParent()->getRecipeList().erase(getIterator());
+}
+
 void VPInstruction::generateInstruction(VPTransformState &State,
                                         unsigned Part) {
   IRBuilder<> &Builder = State.Builder;
Index: llvm/trunk/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/trunk/lib/Transforms/Vectorize/VPlan.h
+++ llvm/trunk/lib/Transforms/Vectorize/VPlan.h
@@ -556,6 +556,11 @@
   /// Insert an unlinked recipe into a basic block immediately before
   /// the specified recipe.
   void insertBefore(VPRecipeBase *InsertPos);
+
+  /// This method unlinks 'this' from the containing basic block and deletes it.
+  ///
+  /// \returns an iterator pointing to the element after the erased one
+  iplist<VPRecipeBase>::iterator eraseFromParent();
 };
 
 /// This is a concrete Recipe that models a single VPlan-level instruction.
Index: llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp
===================================================================
--- llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -40,5 +40,25 @@
   CHECK_ITERATOR(VPBB1, I3, I2, I1);
 }
 
+TEST(VPInstructionTest, eraseFromParent) {
+  VPInstruction *I1 = new VPInstruction(0, {});
+  VPInstruction *I2 = new VPInstruction(1, {});
+  VPInstruction *I3 = new VPInstruction(2, {});
+
+  VPBasicBlock VPBB1;
+  VPBB1.appendRecipe(I1);
+  VPBB1.appendRecipe(I2);
+  VPBB1.appendRecipe(I3);
+
+  I2->eraseFromParent();
+  CHECK_ITERATOR(VPBB1, I1, I3);
+
+  I1->eraseFromParent();
+  CHECK_ITERATOR(VPBB1, I3);
+
+  I3->eraseFromParent();
+  EXPECT_TRUE(VPBB1.empty());
+}
+
 } // namespace
 } // namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48081.151719.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180618/871d6c46/attachment.bin>


More information about the llvm-commits mailing list