@@ -502,6 +502,8 @@ void CopyPropagation::propagateCopies(
502
502
// at least once and then until each stops making changes.
503
503
while (true ) {
504
504
SmallVector<CopyValueInst *, 4 > modifiedCopyValueInsts;
505
+ if (!continueWithNextSubpassRun (bbi))
506
+ return ;
505
507
auto shrunk = shrinkBorrowScope (*bbi, deleter, calleeAnalysis,
506
508
modifiedCopyValueInsts);
507
509
for (auto *cvi : modifiedCopyValueInsts)
@@ -516,25 +518,35 @@ void CopyPropagation::propagateCopies(
516
518
if (borrowee->getOwnershipKind () != OwnershipKind::Owned)
517
519
break ;
518
520
521
+ if (!continueWithNextSubpassRun (borrowee))
522
+ return ;
519
523
auto canonicalized = canonicalizer.canonicalizeValueLifetime (borrowee);
520
524
if (!canonicalized && !firstRun)
521
525
break ;
522
526
527
+ if (!continueWithNextSubpassRun (bbi))
528
+ return ;
523
529
auto folded = foldDestroysOfCopiedLexicalBorrow (bbi, *domTree, deleter);
524
530
if (!folded)
525
531
break ;
526
532
auto hoisted = canonicalizer.canonicalizeValueLifetime (folded);
527
533
// Keep running even if the new move's destroys can't be hoisted.
528
534
(void )hoisted;
535
+ if (!continueWithNextSubpassRun (folded))
536
+ return ;
529
537
eliminateRedundantMove (folded, deleter, defWorklist);
530
538
firstRun = false ;
531
539
}
532
540
}
533
541
for (auto *mvi : moveValues) {
542
+ if (!continueWithNextSubpassRun (mvi))
543
+ return ;
534
544
eliminateRedundantMove (mvi, deleter, defWorklist);
535
545
}
536
546
for (auto *argument : f->getArguments ()) {
537
547
if (argument->getOwnershipKind () == OwnershipKind::Owned) {
548
+ if (!continueWithNextSubpassRun (argument))
549
+ return ;
538
550
canonicalizer.canonicalizeValueLifetime (argument);
539
551
}
540
552
}
@@ -572,8 +584,12 @@ void CopyPropagation::propagateCopies(
572
584
// they may be chained, and CanonicalizeBorrowScopes pushes them
573
585
// top-down.
574
586
for (auto result : ownedForward->getResults ()) {
587
+ if (!continueWithNextSubpassRun (result))
588
+ return ;
575
589
canonicalizer.canonicalizeValueLifetime (result);
576
590
}
591
+ if (!continueWithNextSubpassRun (ownedForward))
592
+ return ;
577
593
if (sinkOwnedForward (ownedForward, postOrderAnalysis, domTree)) {
578
594
changed = true ;
579
595
// Sinking 'ownedForward' may create an opportunity to sink its
@@ -595,6 +611,8 @@ void CopyPropagation::propagateCopies(
595
611
BorrowedValue borrow (defWorklist.borrowedValues .pop_back_val ());
596
612
assert (canonicalizeBorrows || !borrow.isLocalScope ());
597
613
614
+ if (!continueWithNextSubpassRun (borrow.value ))
615
+ return ;
598
616
borrowCanonicalizer.canonicalizeBorrowScope (borrow);
599
617
for (CopyValueInst *copy : borrowCanonicalizer.getUpdatedCopies ()) {
600
618
defWorklist.updateForCopy (copy);
@@ -611,6 +629,8 @@ void CopyPropagation::propagateCopies(
611
629
// Canonicalize all owned defs.
612
630
while (!defWorklist.ownedValues .empty ()) {
613
631
SILValue def = defWorklist.ownedValues .pop_back_val ();
632
+ if (!continueWithNextSubpassRun (def))
633
+ return ;
614
634
auto canonicalized = canonicalizer.canonicalizeValueLifetime (def);
615
635
if (!canonicalized)
616
636
continue ;
0 commit comments