@@ -49,6 +49,44 @@ struct MockedPartitionOpEvaluator final
4949 }
5050
5151 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+ }
5290};
5391
5492} // namespace
@@ -71,6 +109,8 @@ SILInstruction *instSingletons[5] = {
71109 (SILInstruction *)0xBBDA0000 ,
72110};
73111
112+ SILLocation fakeLoc = SILLocation::invalid();
113+
74114// This test tests that if a series of merges is split between two partitions
75115// p1 and p2, but also applied in its entirety to p3, then joining p1 and p2
76116// yields p3.
@@ -198,8 +238,8 @@ TEST(PartitionUtilsTest, Join1) {
198238
199239 Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
200240 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 ());
203243
204244 {
205245 MockedPartitionOpEvaluator eval (p1, factory);
@@ -211,8 +251,8 @@ TEST(PartitionUtilsTest, Join1) {
211251 PartitionOp::Assign (Element (5 ), Element (2 ))});
212252 }
213253
214- Partition p2 =
215- Partition::separateRegions ( llvm::ArrayRef (data1), historyFactory.get ());
254+ Partition p2 = Partition::separateRegions (fakeLoc, llvm::ArrayRef (data1),
255+ historyFactory.get ());
216256 {
217257 MockedPartitionOpEvaluator eval (p2, factory);
218258 eval.apply ({PartitionOp::Assign (Element (0 ), Element (0 )),
@@ -240,8 +280,8 @@ TEST(PartitionUtilsTest, Join2) {
240280
241281 Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
242282 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 ());
245285
246286 {
247287 MockedPartitionOpEvaluator eval (p1, factory);
@@ -255,8 +295,8 @@ TEST(PartitionUtilsTest, Join2) {
255295
256296 Element data2[] = {Element (4 ), Element (5 ), Element (6 ),
257297 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 ());
260300 {
261301 MockedPartitionOpEvaluator eval (p2, factory);
262302 eval.apply ({PartitionOp::Assign (Element (4 ), Element (4 )),
@@ -288,8 +328,8 @@ TEST(PartitionUtilsTest, Join2Reversed) {
288328
289329 Element data1[] = {Element (0 ), Element (1 ), Element (2 ),
290330 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 ());
293333
294334 {
295335 MockedPartitionOpEvaluator eval (p1, factory);
@@ -303,8 +343,8 @@ TEST(PartitionUtilsTest, Join2Reversed) {
303343
304344 Element data2[] = {Element (4 ), Element (5 ), Element (6 ),
305345 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 ());
308348 {
309349 MockedPartitionOpEvaluator eval (p2, factory);
310350 eval.apply ({PartitionOp::Assign (Element (4 ), Element (4 )),
@@ -341,8 +381,8 @@ TEST(PartitionUtilsTest, JoinLarge) {
341381 Element (15 ), Element (16 ), Element (17 ), Element (18 ), Element (19 ),
342382 Element (20 ), Element (21 ), Element (22 ), Element (23 ), Element (24 ),
343383 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 ());
346386 {
347387 MockedPartitionOpEvaluator eval (p1, factory);
348388 eval.apply ({PartitionOp::Assign (Element (0 ), Element (29 )),
@@ -384,8 +424,8 @@ TEST(PartitionUtilsTest, JoinLarge) {
384424 Element (30 ), Element (31 ), Element (32 ), Element (33 ), Element (34 ),
385425 Element (35 ), Element (36 ), Element (37 ), Element (38 ), Element (39 ),
386426 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 ());
389429 {
390430 MockedPartitionOpEvaluator eval (p2, factory);
391431 eval.apply ({PartitionOp::Assign (Element (15 ), Element (31 )),
@@ -558,36 +598,6 @@ TEST(PartitionUtilsTest, TestAssign) {
558598 EXPECT_TRUE (Partition::equals (p1, p3));
559599}
560600
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-
591601// This test tests that consumption consumes entire regions as expected
592602TEST (PartitionUtilsTest, TestConsumeAndRequire) {
593603 llvm::BumpPtrAllocator allocator;
0 commit comments