9
9
10
10
#include " ../lib/Transforms/Vectorize/VPlan.h"
11
11
#include " ../lib/Transforms/Vectorize/VPlanDominatorTree.h"
12
+ #include " VPlanTestBase.h"
12
13
#include " gtest/gtest.h"
13
14
14
15
namespace llvm {
15
16
namespace {
16
17
17
- TEST (VPDominatorTreeTest, DominanceNoRegionsTest) {
18
+ using VPDominatorTreeTest = VPlanTestBase;
19
+
20
+ TEST_F (VPDominatorTreeTest, DominanceNoRegionsTest) {
18
21
// VPBB0
19
22
// |
20
23
// R1 {
@@ -24,8 +27,8 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
24
27
// \ /
25
28
// VPBB4
26
29
// }
27
- VPBasicBlock *VPPH = new VPBasicBlock ( " ph " );
28
- VPBasicBlock *VPBB0 = new VPBasicBlock ( " VPBB0 " );
30
+ VPlan &Plan = getPlan ( );
31
+ VPBasicBlock *VPBB0 = Plan. getEntry ( );
29
32
VPBasicBlock *VPBB1 = new VPBasicBlock (" VPBB1" );
30
33
VPBasicBlock *VPBB2 = new VPBasicBlock (" VPBB2" );
31
34
VPBasicBlock *VPBB3 = new VPBasicBlock (" VPBB3" );
@@ -40,12 +43,7 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
40
43
VPBlockUtils::connectBlocks (VPBB2, VPBB4);
41
44
VPBlockUtils::connectBlocks (VPBB3, VPBB4);
42
45
43
- LLVMContext C;
44
- auto *ScalarHeader = BasicBlock::Create (C, " " );
45
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock (ScalarHeader);
46
- VPBlockUtils::connectBlocks (R1, ScalarHeaderVPBB);
47
- VPBlockUtils::connectBlocks (VPPH, VPBB0);
48
- VPlan Plan (VPPH, ScalarHeaderVPBB);
46
+ VPBlockUtils::connectBlocks (R1, Plan.getScalarHeader ());
49
47
50
48
VPDominatorTree VPDT;
51
49
VPDT.recalculate (Plan);
@@ -62,7 +60,6 @@ TEST(VPDominatorTreeTest, DominanceNoRegionsTest) {
62
60
EXPECT_EQ (VPDT.findNearestCommonDominator (VPBB2, VPBB3), VPBB1);
63
61
EXPECT_EQ (VPDT.findNearestCommonDominator (VPBB2, VPBB4), VPBB1);
64
62
EXPECT_EQ (VPDT.findNearestCommonDominator (VPBB4, VPBB4), VPBB4);
65
- delete ScalarHeader;
66
63
}
67
64
68
65
static void
@@ -76,9 +73,7 @@ checkDomChildren(VPDominatorTree &VPDT, VPBlockBase *Src,
76
73
EXPECT_EQ (Children, ExpectedNodes);
77
74
}
78
75
79
- TEST (VPDominatorTreeTest, DominanceRegionsTest) {
80
- LLVMContext C;
81
- auto *ScalarHeader = BasicBlock::Create (C, " " );
76
+ TEST_F (VPDominatorTreeTest, DominanceRegionsTest) {
82
77
{
83
78
// 2 consecutive regions.
84
79
// VPBB0
@@ -99,8 +94,8 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
99
94
// R2BB2
100
95
// }
101
96
//
102
- VPBasicBlock *VPPH = new VPBasicBlock ( " ph " );
103
- VPBasicBlock *VPBB0 = new VPBasicBlock ( " VPBB0 " );
97
+ VPlan &Plan = getPlan ( );
98
+ VPBasicBlock *VPBB0 = Plan. getEntry ( );
104
99
VPBasicBlock *R1BB1 = new VPBasicBlock ();
105
100
VPBasicBlock *R1BB2 = new VPBasicBlock ();
106
101
VPBasicBlock *R1BB3 = new VPBasicBlock ();
@@ -122,10 +117,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
122
117
VPBlockUtils::connectBlocks (R2BB1, R2BB2);
123
118
VPBlockUtils::connectBlocks (R1, R2);
124
119
125
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock (ScalarHeader);
126
- VPBlockUtils::connectBlocks (R2, ScalarHeaderVPBB);
127
- VPBlockUtils::connectBlocks (VPPH, VPBB0);
128
- VPlan Plan (VPPH, ScalarHeaderVPBB);
120
+ VPBlockUtils::connectBlocks (R2, Plan.getScalarHeader ());
129
121
VPDominatorTree VPDT;
130
122
VPDT.recalculate (Plan);
131
123
@@ -177,7 +169,7 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
177
169
// |
178
170
// VPBB2
179
171
//
180
- VPBasicBlock *VPPH = new VPBasicBlock ( " ph " );
172
+ VPlan &Plan = getPlan ( );
181
173
VPBasicBlock *R1BB1 = new VPBasicBlock (" R1BB1" );
182
174
VPBasicBlock *R1BB2 = new VPBasicBlock (" R1BB2" );
183
175
VPBasicBlock *R1BB3 = new VPBasicBlock (" R1BB3" );
@@ -199,15 +191,12 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
199
191
VPBlockUtils::connectBlocks (R1BB2, R1BB3);
200
192
VPBlockUtils::connectBlocks (R2, R1BB3);
201
193
202
- VPBasicBlock *VPBB1 = new VPBasicBlock ( " VPBB1 " );
194
+ VPBasicBlock *VPBB1 = Plan. getEntry ( );
203
195
VPBlockUtils::connectBlocks (VPBB1, R1);
204
196
VPBasicBlock *VPBB2 = new VPBasicBlock (" VPBB2" );
205
197
VPBlockUtils::connectBlocks (R1, VPBB2);
206
198
207
- VPIRBasicBlock *ScalarHeaderVPBB = new VPIRBasicBlock (ScalarHeader);
208
- VPBlockUtils::connectBlocks (VPBB2, ScalarHeaderVPBB);
209
- VPBlockUtils::connectBlocks (VPPH, VPBB1);
210
- VPlan Plan (VPPH, ScalarHeaderVPBB);
199
+ VPBlockUtils::connectBlocks (VPBB2, Plan.getScalarHeader ());
211
200
VPDominatorTree VPDT;
212
201
VPDT.recalculate (Plan);
213
202
@@ -220,9 +209,8 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) {
220
209
checkDomChildren (VPDT, R2BB2, {R2BB3});
221
210
checkDomChildren (VPDT, R2BB3, {});
222
211
checkDomChildren (VPDT, R1BB3, {VPBB2});
223
- checkDomChildren (VPDT, VPBB2, {ScalarHeaderVPBB });
212
+ checkDomChildren (VPDT, VPBB2, {Plan. getScalarHeader () });
224
213
}
225
- delete ScalarHeader;
226
214
}
227
215
228
216
} // namespace
0 commit comments