Skip to content

Commit 659c369

Browse files
committed
[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
1 parent 33411d5 commit 659c369

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
4444
LLVMContext C;
4545
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
4646
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
47+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
4748
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
4849

4950
VPDominatorTree VPDT;
@@ -122,6 +123,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
122123

123124
auto TC = std::make_unique<VPValue>();
124125
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
126+
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
125127
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
126128
VPDominatorTree VPDT;
127129
VPDT.recalculate(Plan);
@@ -203,6 +205,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
203205

204206
auto TC = std::make_unique<VPValue>();
205207
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
208+
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
206209
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
207210
VPDominatorTree VPDT;
208211
VPDT.recalculate(Plan);
@@ -216,7 +219,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
216219
checkDomChildren(VPDT, R2BB2, {R2BB3});
217220
checkDomChildren(VPDT, R2BB3, {});
218221
checkDomChildren(VPDT, R1BB3, {VPBB2});
219-
checkDomChildren(VPDT, VPBB2, {});
222+
checkDomChildren(VPDT, VPBB2, {ScalarHeaderVPBB});
220223
}
221224
}
222225

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ TEST(VPBasicBlockTest, getPlan) {
259259

260260
auto TC = std::make_unique<VPValue>();
261261
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
262+
VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
262263
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
263264

264265
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -280,6 +281,7 @@ TEST(VPBasicBlockTest, getPlan) {
280281

281282
auto TC = std::make_unique<VPValue>();
282283
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
284+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
283285
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
284286

285287
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -311,6 +313,7 @@ TEST(VPBasicBlockTest, getPlan) {
311313

312314
auto TC = std::make_unique<VPValue>();
313315
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
316+
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
314317
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
315318

316319
EXPECT_EQ(&Plan, VPBB1->getPlan());
@@ -355,6 +358,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
355358
// Use Plan to properly clean up created blocks.
356359
auto TC = std::make_unique<VPValue>();
357360
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
361+
VPBlockUtils::connectBlocks(VPBB4, ScalarHeaderVPBB);
358362
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
359363
}
360364

@@ -456,6 +460,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
456460
// Use Plan to properly clean up created blocks.
457461
auto TC = std::make_unique<VPValue>();
458462
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
463+
VPBlockUtils::connectBlocks(R2, ScalarHeaderVPBB);
459464
VPlan Plan(VPPH, &*TC, VPBB0, ScalarHeaderVPBB);
460465
}
461466

@@ -540,6 +545,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
540545
// Use Plan to properly clean up created blocks.
541546
auto TC = std::make_unique<VPValue>();
542547
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
548+
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
543549
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
544550
}
545551

@@ -589,6 +595,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
589595
// Use Plan to properly clean up created blocks.
590596
auto TC = std::make_unique<VPValue>();
591597
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
598+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
592599
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
593600
}
594601

@@ -682,6 +689,7 @@ TEST(VPBasicBlockTest, TraversingIteratorTest) {
682689
// Use Plan to properly clean up created blocks.
683690
auto TC = std::make_unique<VPValue>();
684691
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
692+
VPBlockUtils::connectBlocks(VPBB2, ScalarHeaderVPBB);
685693
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
686694
}
687695
}
@@ -808,6 +816,7 @@ TEST(VPBasicBlockTest, printPlanWithVFsAndUFs) {
808816
LLVMContext C;
809817
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
810818
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
819+
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
811820
VPlan Plan(VPBB0, TC, VPBB1, ScalarHeaderVPBB);
812821
Plan.setName("TestPlan");
813822
Plan.addVF(ElementCount::getFixed(4));
@@ -826,6 +835,9 @@ No successors
826835
827836
bb1:
828837
EMIT vp<%2> = add
838+
Successor(s): ir-bb<>
839+
840+
ir-bb<>:
829841
No successors
830842
}
831843
)";
@@ -847,6 +859,9 @@ No successors
847859
848860
bb1:
849861
EMIT vp<%2> = add
862+
Successor(s): ir-bb<>
863+
864+
ir-bb<>:
850865
No successors
851866
}
852867
)";
@@ -868,6 +883,9 @@ No successors
868883
869884
bb1:
870885
EMIT vp<%2> = add
886+
Successor(s): ir-bb<>
887+
888+
ir-bb<>:
871889
No successors
872890
}
873891
)";
@@ -1271,6 +1289,7 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
12711289
LLVMContext C;
12721290
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
12731291
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
1292+
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
12741293
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
12751294

12761295
IntegerType *Int32 = IntegerType::get(C, 32);
@@ -1341,6 +1360,7 @@ TEST(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
13411360
LLVMContext C;
13421361
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
13431362
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
1363+
VPBlockUtils::connectBlocks(VPBB1, ScalarHeaderVPBB);
13441364
VPlan Plan(VPBB0, VPBB1, ScalarHeaderVPBB);
13451365

13461366
IntegerType *Int32 = IntegerType::get(C, 32);

llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
3232
LLVMContext C;
3333
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
3434
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
35+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
3536
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
3637

3738
#if GTEST_HAS_STREAM_REDIRECTION
@@ -67,6 +68,7 @@ TEST(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
6768
LLVMContext C;
6869
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
6970
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
71+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
7072
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
7173

7274
#if GTEST_HAS_STREAM_REDIRECTION
@@ -112,6 +114,7 @@ TEST(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
112114
auto TC = std::make_unique<VPValue>();
113115
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
114116
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
117+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
115118
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
116119

117120
#if GTEST_HAS_STREAM_REDIRECTION
@@ -151,6 +154,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
151154
LLVMContext C;
152155
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
153156
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
157+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
154158
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
155159

156160
#if GTEST_HAS_STREAM_REDIRECTION
@@ -191,6 +195,7 @@ TEST(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
191195
LLVMContext C;
192196
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
193197
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
198+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
194199
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
195200

196201
#if GTEST_HAS_STREAM_REDIRECTION
@@ -223,6 +228,7 @@ TEST(VPVerifierTest, BlockOutsideRegionWithParent) {
223228
LLVMContext C;
224229
auto ScalarHeader = std::make_unique<BasicBlock *>(BasicBlock::Create(C, ""));
225230
VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock(*ScalarHeader);
231+
VPBlockUtils::connectBlocks(R1, ScalarHeaderVPBB);
226232
VPlan Plan(VPPH, &*TC, VPBB1, ScalarHeaderVPBB);
227233

228234
#if GTEST_HAS_STREAM_REDIRECTION

0 commit comments

Comments
 (0)