@@ -620,89 +620,6 @@ SILBasicBlock *swift::splitIfCriticalEdge(SILBasicBlock *from,
620
620
llvm_unreachable (" Destination block not found" );
621
621
}
622
622
623
- void swift::completeJointPostDominanceSet (
624
- ArrayRef<SILBasicBlock *> userBlocks, ArrayRef<SILBasicBlock *> defBlocks,
625
- llvm::SmallVectorImpl<SILBasicBlock *> &result) {
626
- assert (!userBlocks.empty () && " Must have at least 1 user block" );
627
- assert (!defBlocks.empty () && " Must have at least 1 def block" );
628
-
629
- // If we have only one def block and one user block and they are the same
630
- // block, then just return.
631
- if (defBlocks.size () == 1 && userBlocks.size () == 1
632
- && userBlocks[0 ] == defBlocks[0 ]) {
633
- return ;
634
- }
635
-
636
- // Some notes on the algorithm:
637
- //
638
- // 1. Our VisitedBlocks set just states that a value has been added to the
639
- // worklist and should not be added to the worklist.
640
- // 2. Our targets of the CFG block are DefBlockSet.
641
- // 3. We find the missing post-domination blocks by finding successors of
642
- // blocks on our walk that we have not visited by the end of the walk. For
643
- // joint post-dominance to be true, no such successors should exist.
644
-
645
- // Our set of target blocks where we stop walking.
646
- llvm::SmallPtrSet<SILBasicBlock *, 8 > defBlockSet (defBlocks.begin (),
647
- defBlocks.end ());
648
-
649
- // The set of successor blocks of blocks that we visit. Any blocks still in
650
- // this set at the end of the walk act as a post-dominating closure around our
651
- // userBlock set.
652
- llvm::SmallSetVector<SILBasicBlock *, 16 > mustVisitSuccessorBlocks;
653
-
654
- // Add our user and def blocks to the visitedBlock set. We never want to find
655
- // these in our worklist.
656
- llvm::SmallPtrSet<SILBasicBlock *, 32 > visitedBlocks (userBlocks.begin (),
657
- userBlocks.end ());
658
-
659
- // Finally setup our worklist by adding our user block predecessors. We only
660
- // add the predecessors to the worklist once.
661
- llvm::SmallVector<SILBasicBlock *, 32 > worklist;
662
- for (auto *block : userBlocks) {
663
- llvm::copy_if (block->getPredecessorBlocks (), std::back_inserter (worklist),
664
- [&](SILBasicBlock *predBlock) -> bool {
665
- return visitedBlocks.insert (predBlock).second ;
666
- });
667
- }
668
-
669
- // Then until we reach a fix point.
670
- while (!worklist.empty ()) {
671
- // Grab the next block from the worklist.
672
- auto *block = worklist.pop_back_val ();
673
- assert (visitedBlocks.count (block)
674
- && " All blocks from worklist should be "
675
- " in the visited blocks set." );
676
-
677
- // Since we are visiting this block now, we know that this block can not be
678
- // apart of a the post-dominance closure of our UseBlocks.
679
- mustVisitSuccessorBlocks.remove (block);
680
-
681
- // Then add each successor block of block that has not been visited yet to
682
- // the mustVisitSuccessorBlocks set.
683
- for (auto *succBlock : block->getSuccessorBlocks ()) {
684
- if (!visitedBlocks.count (succBlock)) {
685
- mustVisitSuccessorBlocks.insert (succBlock);
686
- }
687
- }
688
-
689
- // If this is a def block, then do not add its predecessors to the
690
- // worklist.
691
- if (defBlockSet.count (block))
692
- continue ;
693
-
694
- // Otherwise add all unvisited predecessors to the worklist.
695
- llvm::copy_if (block->getPredecessorBlocks (), std::back_inserter (worklist),
696
- [&](SILBasicBlock *block) -> bool {
697
- return visitedBlocks.insert (block).second ;
698
- });
699
- }
700
-
701
- // Now that we are done, add all remaining must visit blocks to our result
702
- // list. These are the remaining parts of our joint post-dominance closure.
703
- llvm::copy (mustVisitSuccessorBlocks, std::back_inserter (result));
704
- }
705
-
706
623
bool swift::splitAllCondBrCriticalEdgesWithNonTrivialArgs (
707
624
SILFunction &fn, DominanceInfo *domInfo, SILLoopInfo *loopInfo) {
708
625
// Find our targets.
0 commit comments