[llvm] r334951 - [VPlanRecipeBase] Add eraseFromParent().
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 18 08:18:48 PDT 2018
Author: fhahn
Date: Mon Jun 18 08:18:48 2018
New Revision: 334951
URL: http://llvm.org/viewvc/llvm-project?rev=334951&view=rev
Log:
[VPlanRecipeBase] Add eraseFromParent().
Reviewers: dcaballe, hsaito, mkuper, hfinkel
Reviewed By: dcaballe
Differential Revision: https://reviews.llvm.org/D48081
Modified:
llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
llvm/trunk/lib/Transforms/Vectorize/VPlan.h
llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp?rev=334951&r1=334950&r2=334951&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/VPlan.cpp Mon Jun 18 08:18:48 2018
@@ -225,6 +225,10 @@ void VPRecipeBase::insertBefore(VPRecipe
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;
Modified: llvm/trunk/lib/Transforms/Vectorize/VPlan.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/VPlan.h?rev=334951&r1=334950&r2=334951&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/VPlan.h (original)
+++ llvm/trunk/lib/Transforms/Vectorize/VPlan.h Mon Jun 18 08:18:48 2018
@@ -556,6 +556,11 @@ public:
/// 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.
Modified: llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp?rev=334951&r1=334950&r2=334951&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp (original)
+++ llvm/trunk/unittests/Transforms/Vectorize/VPlanTest.cpp Mon Jun 18 08:18:48 2018
@@ -40,5 +40,25 @@ TEST(VPInstructionTest, insertBefore) {
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
More information about the llvm-commits
mailing list