[PATCH] D48081: [VPlanRecipeBase] Add eraseFromParent().
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 08:33:33 PDT 2018
fhahn created this revision.
fhahn added reviewers: dcaballe, hsaito, mkuper, hfinkel.
Herald added subscribers: rogfer01, rkruppe, tschuett, bollu.
https://reviews.llvm.org/D48081
Files:
lib/Transforms/Vectorize/VPlan.cpp
lib/Transforms/Vectorize/VPlan.h
unittests/Transforms/Vectorize/VPlanTest.cpp
Index: unittests/Transforms/Vectorize/VPlanTest.cpp
===================================================================
--- unittests/Transforms/Vectorize/VPlanTest.cpp
+++ unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -66,6 +66,27 @@
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());
+}
+
+
TEST(VPInstructionTest, sinkInstructions) {
// Create some dummy instructions, we need those for the SinkAfter mapping.
LLVMContext Context;
Index: lib/Transforms/Vectorize/VPlan.h
===================================================================
--- lib/Transforms/Vectorize/VPlan.h
+++ lib/Transforms/Vectorize/VPlan.h
@@ -560,6 +560,11 @@
/// Insert an unlinked instruction into a basic block immediately before
/// the specified instruction.
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: lib/Transforms/Vectorize/VPlan.cpp
===================================================================
--- lib/Transforms/Vectorize/VPlan.cpp
+++ lib/Transforms/Vectorize/VPlan.cpp
@@ -231,6 +231,10 @@
this);
}
+iplist<VPRecipeBase>::iterator VPRecipeBase::eraseFromParent() {
+ return getParent()->getRecipeList().erase(getIterator());
+}
+
void VPInstruction::generateInstruction(VPTransformState &State,
unsigned Part) {
IRBuilder<> &Builder = State.Builder;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48081.150950.patch
Type: text/x-patch
Size: 2139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/fea6bc26/attachment.bin>
More information about the llvm-commits
mailing list