[llvm] 659c369 - [VPlan] Connect scalar header to VPlan CFG in unit tests.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 02:50:49 PDT 2024
Author: Florian Hahn
Date: 2024-11-01T09:47:40Z
New Revision: 659c3699e836d022f4bf02db8910fa3ec5e32fd2
URL: https://github.com/llvm/llvm-project/commit/659c3699e836d022f4bf02db8910fa3ec5e32fd2
DIFF: https://github.com/llvm/llvm-project/commit/659c3699e836d022f4bf02db8910fa3ec5e32fd2.diff
LOG: [VPlan] Connect scalar header to VPlan CFG in unit tests.
This ensures the VPIRBasicBlocks are deleted when the VPlan is
destroyed.
Fixes a buildbot failure with ASAN, including
https://lab.llvm.org/buildbot/#/builders/52/builds/3368
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 37c505e8b37904..474f7b909ab6e9 100644
--- a/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp
@@ -44,6 +44,7 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
VPDominatorTree VPDT;
@@ -122,6 +123,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
VPDominatorTree VPDT;
VPDT.recalculate(Plan);
@@ -203,6 +205,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
VPDominatorTree VPDT;
VPDT.recalculate(Plan);
@@ -216,7 +219,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
checkDomChildren(VPDT, R2BB2, {R2BB3});
checkDomChildren(VPDT, R2BB3, {});
checkDomChildren(VPDT, R1BB3, {VPBB2});
- checkDomChildren(VPDT, VPBB2, {});
+ checkDomChildren(VPDT, VPBB2, {ScalarHeaderVPBB});
}
}
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index ae0122cd67916d..2f9ca07341298d 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -259,6 +259,7 @@ TEST(VPBasicBlockTest, getPlan) {
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -280,6 +281,7 @@ TEST(VPBasicBlockTest, getPlan) {
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -311,6 +313,7 @@ TEST(VPBasicBlockTest, getPlan) {
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -355,6 +358,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -456,6 +460,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
}
@@ -540,6 +545,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -589,6 +595,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
@@ -682,6 +689,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
// Use Plan to properly clean up created blocks.
auto TC = std::make_unique<VPValue>();
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
}
}
@@ -808,6 +816,7 @@ TEST(VPBasicBlockTest, printPlanWithVFsAndUFs) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, TC, VPBB1, ScalarHeaderVPBB);
Plan.setName("TestPlan");
Plan.addVF(ElementCount::getFixed(4));
@@ -826,6 +835,9 @@ No successors
bb1:
EMIT vp<%2> = add
+Successor(s): ir-bb<>
+
+ir-bb<>:
No successors
}
)";
@@ -847,6 +859,9 @@ No successors
bb1:
EMIT vp<%2> = add
+Successor(s): ir-bb<>
+
+ir-bb<>:
No successors
}
)";
@@ -868,6 +883,9 @@ No successors
bb1:
EMIT vp<%2> = add
+Successor(s): ir-bb<>
+
+ir-bb<>:
No successors
}
)";
@@ -1271,6 +1289,7 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
IntegerType *Int32 = IntegerType::get(C, 32);
@@ -1341,6 +1360,7 @@ TEST(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
IntegerType *Int32 = IntegerType::get(C, 32);
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
index e70cd271b8d732..98777a460d32f3 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
@@ -32,6 +32,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
@@ -67,6 +68,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
@@ -112,6 +114,7 @@ TEST(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
auto TC = std::make_unique<VPValue>();
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
@@ -151,6 +154,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
@@ -191,6 +195,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
@@ -223,6 +228,7 @@ TEST(VPVerifierTest, BlockOutsideRegionWithParent) {
LLVMContext C;
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
+ VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
#if GTEST_HAS_STREAM_REDIRECTION
More information about the llvm-commits
mailing list