@@ -49,6 +49,44 @@ struct MockedPartitionOpEvaluator final
49
49
}
50
50
51
51
bool shouldTryToSquelchErrors () const { return false ; }
52
+
53
+ static SILLocation getLoc (SILInstruction *inst) {
54
+ return SILLocation::invalid ();
55
+ }
56
+ };
57
+
58
+ } // namespace
59
+
60
+ namespace {
61
+
62
+ struct MockedPartitionOpEvaluatorWithFailureCallback final
63
+ : PartitionOpEvaluatorBaseImpl<
64
+ MockedPartitionOpEvaluatorWithFailureCallback> {
65
+ using FailureCallbackTy =
66
+ std::function<void (const PartitionOp &, unsigned , TransferringOperand *)>;
67
+ FailureCallbackTy failureCallback;
68
+
69
+ MockedPartitionOpEvaluatorWithFailureCallback (
70
+ Partition &workingPartition, TransferringOperandSetFactory &ptrSetFactory,
71
+ FailureCallbackTy failureCallback)
72
+ : PartitionOpEvaluatorBaseImpl(workingPartition, ptrSetFactory),
73
+ failureCallback (failureCallback) {}
74
+
75
+ void handleLocalUseAfterTransfer (const PartitionOp &op, Element elt,
76
+ TransferringOperand *transferringOp) const {
77
+ failureCallback (op, elt, transferringOp);
78
+ }
79
+
80
+ // Just say that we always have a disconnected value.
81
+ SILIsolationInfo getIsolationRegionInfo (Element elt) const {
82
+ return SILIsolationInfo::getDisconnected ();
83
+ }
84
+
85
+ bool shouldTryToSquelchErrors () const { return false ; }
86
+
87
+ static SILLocation getLoc (SILInstruction *inst) {
88
+ return SILLocation::invalid ();
89
+ }
52
90
};
53
91
54
92
} // namespace
@@ -71,6 +109,8 @@ SILInstruction *instSingletons[5] = {
71
109
(SILInstruction *)0xBBDA0000 ,
72
110
};
73
111
112
+ SILLocation fakeLoc = SILLocation::invalid();
113
+
74
114
// This test tests that if a series of merges is split between two partitions
75
115
// p1 and p2, but also applied in its entirety to p3, then joining p1 and p2
76
116
// yields p3.
@@ -198,8 +238,8 @@ TEST(PartitionUtilsTest, Join1) {
198
238
199
239
Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
200
240
Element (3 ), Element (4 ), Element (5 )};
201
- Partition p1 =
202
- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
241
+ Partition p1 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
242
+ historyFactory.get ());
203
243
204
244
{
205
245
MockedPartitionOpEvaluator eval (p1, factory);
@@ -211,8 +251,8 @@ TEST(PartitionUtilsTest, Join1) {
211
251
PartitionOp::Assign (Element (5 ), Element (2 ))});
212
252
}
213
253
214
- Partition p2 =
215
- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
254
+ Partition p2 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
255
+ historyFactory.get ());
216
256
{
217
257
MockedPartitionOpEvaluator eval (p2, factory);
218
258
eval.apply ({PartitionOp::Assign (Element (0 ), Element (0 )),
@@ -240,8 +280,8 @@ TEST(PartitionUtilsTest, Join2) {
240
280
241
281
Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
242
282
Element (3 ), Element (4 ), Element (5 )};
243
- Partition p1 =
244
- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
283
+ Partition p1 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
284
+ historyFactory.get ());
245
285
246
286
{
247
287
MockedPartitionOpEvaluator eval (p1, factory);
@@ -255,8 +295,8 @@ TEST(PartitionUtilsTest, Join2) {
255
295
256
296
Element data2[] = {Element (4 ), Element (5 ), Element (6 ),
257
297
Element (7 ), Element (8 ), Element (9 )};
258
- Partition p2 =
259
- Partition::separateRegions ( llvm::ArrayRef (data2), historyFactory.get ());
298
+ Partition p2 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data2),
299
+ historyFactory.get ());
260
300
{
261
301
MockedPartitionOpEvaluator eval (p2, factory);
262
302
eval.apply ({PartitionOp::Assign (Element (4 ), Element (4 )),
@@ -288,8 +328,8 @@ TEST(PartitionUtilsTest, Join2Reversed) {
288
328
289
329
Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
290
330
Element (3 ), Element (4 ), Element (5 )};
291
- Partition p1 =
292
- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
331
+ Partition p1 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
332
+ historyFactory.get ());
293
333
294
334
{
295
335
MockedPartitionOpEvaluator eval (p1, factory);
@@ -303,8 +343,8 @@ TEST(PartitionUtilsTest, Join2Reversed) {
303
343
304
344
Element data2[] = {Element (4 ), Element (5 ), Element (6 ),
305
345
Element (7 ), Element (8 ), Element (9 )};
306
- Partition p2 =
307
- Partition::separateRegions ( llvm::ArrayRef (data2), historyFactory.get ());
346
+ Partition p2 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data2),
347
+ historyFactory.get ());
308
348
{
309
349
MockedPartitionOpEvaluator eval (p2, factory);
310
350
eval.apply ({PartitionOp::Assign (Element (4 ), Element (4 )),
@@ -341,8 +381,8 @@ TEST(PartitionUtilsTest, JoinLarge) {
341
381
Element (15 ), Element (16 ), Element (17 ), Element (18 ), Element (19 ),
342
382
Element (20 ), Element (21 ), Element (22 ), Element (23 ), Element (24 ),
343
383
Element (25 ), Element (26 ), Element (27 ), Element (28 ), Element (29 )};
344
- Partition p1 =
345
- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
384
+ Partition p1 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
385
+ historyFactory.get ());
346
386
{
347
387
MockedPartitionOpEvaluator eval (p1, factory);
348
388
eval.apply ({PartitionOp::Assign (Element (0 ), Element (29 )),
@@ -384,8 +424,8 @@ TEST(PartitionUtilsTest, JoinLarge) {
384
424
Element (30 ), Element (31 ), Element (32 ), Element (33 ), Element (34 ),
385
425
Element (35 ), Element (36 ), Element (37 ), Element (38 ), Element (39 ),
386
426
Element (40 ), Element (41 ), Element (42 ), Element (43 ), Element (44 )};
387
- Partition p2 =
388
- Partition::separateRegions ( llvm::ArrayRef (data2), historyFactory.get ());
427
+ Partition p2 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data2),
428
+ historyFactory.get ());
389
429
{
390
430
MockedPartitionOpEvaluator eval (p2, factory);
391
431
eval.apply ({PartitionOp::Assign (Element (15 ), Element (31 )),
@@ -558,36 +598,6 @@ TEST(PartitionUtilsTest, TestAssign) {
558
598
EXPECT_TRUE (Partition::equals (p1, p3));
559
599
}
560
600
561
- namespace {
562
-
563
- struct MockedPartitionOpEvaluatorWithFailureCallback final
564
- : PartitionOpEvaluatorBaseImpl<
565
- MockedPartitionOpEvaluatorWithFailureCallback> {
566
- using FailureCallbackTy =
567
- std::function<void (const PartitionOp &, unsigned , TransferringOperand *)>;
568
- FailureCallbackTy failureCallback;
569
-
570
- MockedPartitionOpEvaluatorWithFailureCallback (
571
- Partition &workingPartition, TransferringOperandSetFactory &ptrSetFactory,
572
- FailureCallbackTy failureCallback)
573
- : PartitionOpEvaluatorBaseImpl(workingPartition, ptrSetFactory),
574
- failureCallback (failureCallback) {}
575
-
576
- void handleLocalUseAfterTransfer (const PartitionOp &op, Element elt,
577
- TransferringOperand *transferringOp) const {
578
- failureCallback (op, elt, transferringOp);
579
- }
580
-
581
- // Just say that we always have a disconnected value.
582
- SILIsolationInfo getIsolationRegionInfo (Element elt) const {
583
- return SILIsolationInfo::getDisconnected ();
584
- }
585
-
586
- bool shouldTryToSquelchErrors () const { return false ; }
587
- };
588
-
589
- } // namespace
590
-
591
601
// This test tests that consumption consumes entire regions as expected
592
602
TEST (PartitionUtilsTest, TestConsumeAndRequire) {
593
603
llvm::BumpPtrAllocator allocator;
0 commit comments