[llvm] edd6b1f - [VPlan] Don't leak ScalarHeader BasicBlock in unit tests.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 06:53:16 PDT 2024
Author: Florian Hahn
Date: 2024-11-01T13:52:58Z
New Revision: edd6b1f4fe4838a7a656b2e8c5ac2de3a358d41a
URL: https://github.com/llvm/llvm-project/commit/edd6b1f4fe4838a7a656b2e8c5ac2de3a358d41a
DIFF: https://github.com/llvm/llvm-project/commit/edd6b1f4fe4838a7a656b2e8c5ac2de3a358d41a.diff
LOG: [VPlan] Don't leak ScalarHeader BasicBlock in unit tests.
Added:
Modified:
llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp b/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
index 474f7b909ab6e9..86182ccae0b55b 100644
--- a/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
@@ -42,8 +42,8 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
auto TC = std::make_unique<VPValue>();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
@@ -62,6 +62,7 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
EXPECT_EQ(VPDT.findNearestCommonDominator(VPBB2, VPBB3), VPBB1);
EXPECT_EQ(VPDT.findNearestCommonDominator(VPBB2, VPBB4), VPBB1);
EXPECT_EQ(VPDT.findNearestCommonDominator(VPBB4, VPBB4), VPBB4);
+ delete ScalarHeader;
}
static void
@@ -77,7 +78,7 @@ checkDomChildren(VPDominatorTree &VPDT, VPBlockBase *Src,
TEST(VPDominatorTreeTest, DominanceRegionsTest) {
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
+ auto *ScalarHeader = BasicBlock::Create(C, "");
{
// 2 consecutive regions.
// VPBB0
@@ -122,7 +123,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
VPBlockUtils::connectBlocks(R1, R2);
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
VPDominatorTree VPDT;
@@ -204,7 +205,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
VPBlockUtils::connectBlocks(R1, VPBB2);
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
VPDominatorTree VPDT;
@@ -221,6 +222,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
checkDomChildren(VPDT, R1BB3, {VPBB2});
checkDomChildren(VPDT, VPBB2, {ScalarHeaderVPBB});
}
+ delete ScalarHeader;
}
} // namespace
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 2f9ca07341298d..0f1b52bd453e0f 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -239,7 +239,7 @@ TEST(VPInstructionTest, releaseOperandsAtDeletion) {
}
TEST(VPBasicBlockTest, getPlan) {
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
+ auto *ScalarHeader = BasicBlock::Create(C, "");
{
VPBasicBlock *VPPH = new VPBasicBlock("ph");
VPBasicBlock *VPBB1 = new VPBasicBlock();
@@ -258,7 +258,7 @@ TEST(VPBasicBlockTest, getPlan) {
VPBlockUtils::connectBlocks(VPBB3, VPBB4);
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -280,7 +280,7 @@ TEST(VPBasicBlockTest, getPlan) {
VPBlockUtils::connectBlocks(VPBB1, R1);
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -312,7 +312,7 @@ TEST(VPBasicBlockTest, getPlan) {
VPBlockUtils::connectBlocks(R2, VPBB2);
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -325,11 +325,12 @@ TEST(VPBasicBlockTest, getPlan) {
EXPECT_EQ(&Plan, R2BB2->getPlan());
EXPECT_EQ(&Plan, VPBB2->getPlan());
}
+ delete ScalarHeader;
}
TEST(VPBasicBlockTest, TraversingIteratorTest) {
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
+ auto *ScalarHeader = BasicBlock::Create(C, "");
{
// VPBasicBlocks only
// VPBB1
@@ -357,7 +358,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -459,7 +460,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
}
@@ -544,7 +545,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -594,7 +595,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -688,10 +689,11 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
+ delete ScalarHeader;
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -729,8 +731,8 @@ TEST(VPBasicBlockTest, print) {
}
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPlan Plan(VPBB0, TC, VPBB1, ScalarHeaderVPBB);
std::string FullDump;
raw_string_ostream OS(FullDump);
@@ -800,6 +802,7 @@ No successors
OS << *I4;
EXPECT_EQ("EMIT vp<%5> = mul vp<%3>, vp<%2>", I4Dump);
}
+ delete ScalarHeader;
}
TEST(VPBasicBlockTest, printPlanWithVFsAndUFs) {
@@ -814,8 +817,8 @@ TEST(VPBasicBlockTest, printPlanWithVFsAndUFs) {
VPBB1->setName("bb1");
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, TC, VPBB1, ScalarHeaderVPBB);
Plan.setName("TestPlan");
@@ -891,6 +894,7 @@ No successors
)";
EXPECT_EQ(ExpectedStr, FullDump);
}
+ delete ScalarHeader;
}
#endif
@@ -1287,8 +1291,8 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
VPBasicBlock *VPBB0 = new VPBasicBlock("preheader");
VPBasicBlock *VPBB1 = new VPBasicBlock();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
@@ -1352,14 +1356,15 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
}
delete AI;
+ delete ScalarHeader;
}
TEST(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
VPBasicBlock *VPBB0 = new VPBasicBlock("preheader");
VPBasicBlock *VPBB1 = new VPBasicBlock();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
@@ -1440,6 +1445,7 @@ TEST(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
testing::ExitedWithCode(0), "EMIT vp<%2> = mul vp<%1>, vp<%1>");
}
delete AI;
+ delete ScalarHeader;
}
TEST(VPRecipeTest, dumpRecipeUnnamedVPValuesNotInPlanOrBlock) {
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
index 98777a460d32f3..edb3f8a2952942 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
@@ -30,8 +30,8 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
VPBlockUtils::connectBlocks(VPBB1, R1);
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -43,6 +43,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
EXPECT_STREQ("Use before def!\n",
::testing::internal::GetCapturedStderr().c_str());
#endif
+ delete ScalarHeader;
}
TEST(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
@@ -66,8 +67,8 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
auto TC = std::make_unique<VPValue>();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -79,6 +80,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
EXPECT_STREQ("Use before def!\n",
::testing::internal::GetCapturedStderr().c_str());
#endif
+ delete ScalarHeader;
}
TEST(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
@@ -112,8 +114,8 @@ TEST(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
VPBB3->setParent(R1);
auto TC = std::make_unique<VPValue>();
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -127,6 +129,7 @@ TEST(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
#endif
delete Phi;
+ delete ScalarHeader;
}
TEST(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
@@ -152,8 +155,8 @@ TEST(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
auto TC = std::make_unique<VPValue>();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -165,6 +168,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
EXPECT_STREQ("Multiple instances of the same successor.\n",
::testing::internal::GetCapturedStderr().c_str());
#endif
+ delete ScalarHeader;
}
TEST(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
@@ -193,8 +197,8 @@ TEST(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
auto TC = std::make_unique<VPValue>();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -206,6 +210,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
EXPECT_STREQ("Multiple instances of the same successor.\n",
::testing::internal::GetCapturedStderr().c_str());
#endif
+ delete ScalarHeader;
}
TEST(VPVerifierTest, BlockOutsideRegionWithParent) {
@@ -226,8 +231,8 @@ TEST(VPVerifierTest, BlockOutsideRegionWithParent) {
auto TC = std::make_unique<VPValue>();
LLVMContext C;
- auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ auto *ScalarHeader = BasicBlock::Create(C, "");
+ VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(ScalarHeader);
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
@@ -239,6 +244,7 @@ TEST(VPVerifierTest, BlockOutsideRegionWithParent) {
EXPECT_STREQ("Predecessor is not in the same region.\n",
::testing::internal::GetCapturedStderr().c_str());
#endif
+ delete ScalarHeader;
}
} // namespace
More information about the llvm-commits
mailing list