@@ -582,17 +582,15 @@ struct AllSwitchPaths {
582
582
VisitedBlocks VB;
583
583
// Get paths from the determinator BBs to SwitchPhiDefBB
584
584
std::vector<ThreadingPath> PathsToPhiDef =
585
- getPathsFromStateDefMap (StateDef, SwitchPhi, VB, MaxNumPaths );
585
+ getPathsFromStateDefMap (StateDef, SwitchPhi, VB);
586
586
if (SwitchPhiDefBB == SwitchBlock) {
587
587
TPaths = std::move (PathsToPhiDef);
588
588
return ;
589
589
}
590
590
591
- assert (MaxNumPaths >= PathsToPhiDef.size ());
592
- auto PathsLimit = MaxNumPaths / PathsToPhiDef.size ();
593
591
// Find and append paths from SwitchPhiDefBB to SwitchBlock.
594
592
PathsType PathsToSwitchBB =
595
- paths (SwitchPhiDefBB, SwitchBlock, VB, /* PathDepth = */ 1 , PathsLimit );
593
+ paths (SwitchPhiDefBB, SwitchBlock, VB, /* PathDepth = */ 1 );
596
594
if (PathsToSwitchBB.empty ())
597
595
return ;
598
596
@@ -613,16 +611,13 @@ struct AllSwitchPaths {
613
611
typedef DenseMap<const BasicBlock *, const PHINode *> StateDefMap;
614
612
std::vector<ThreadingPath> getPathsFromStateDefMap (StateDefMap &StateDef,
615
613
PHINode *Phi,
616
- VisitedBlocks &VB,
617
- unsigned PathsLimit) {
614
+ VisitedBlocks &VB) {
618
615
std::vector<ThreadingPath> Res;
619
616
auto *PhiBB = Phi->getParent ();
620
617
VB.insert (PhiBB);
621
618
622
619
VisitedBlocks UniqueBlocks;
623
620
for (auto *IncomingBB : Phi->blocks ()) {
624
- if (Res.size () >= PathsLimit)
625
- break ;
626
621
if (!UniqueBlocks.insert (IncomingBB).second )
627
622
continue ;
628
623
if (!SwitchOuterLoop->contains (IncomingBB))
@@ -658,9 +653,8 @@ struct AllSwitchPaths {
658
653
659
654
// Direct predecessor, just add to the path.
660
655
if (IncomingPhiDefBB == IncomingBB) {
661
- assert (PathsLimit > Res.size ());
662
- std::vector<ThreadingPath> PredPaths = getPathsFromStateDefMap (
663
- StateDef, IncomingPhi, VB, PathsLimit - Res.size ());
656
+ std::vector<ThreadingPath> PredPaths =
657
+ getPathsFromStateDefMap (StateDef, IncomingPhi, VB);
664
658
for (ThreadingPath &Path : PredPaths) {
665
659
Path.push_back (PhiBB);
666
660
Res.push_back (std::move (Path));
@@ -673,17 +667,13 @@ struct AllSwitchPaths {
673
667
continue ;
674
668
675
669
PathsType IntermediatePaths;
676
- assert (PathsLimit > Res.size ());
677
- auto InterPathLimit = PathsLimit - Res.size ();
678
- IntermediatePaths = paths (IncomingPhiDefBB, IncomingBB, VB,
679
- /* PathDepth = */ 1 , InterPathLimit);
670
+ IntermediatePaths =
671
+ paths (IncomingPhiDefBB, IncomingBB, VB, /* PathDepth = */ 1 );
680
672
if (IntermediatePaths.empty ())
681
673
continue ;
682
674
683
- assert (InterPathLimit >= IntermediatePaths.size ());
684
- auto PredPathLimit = InterPathLimit / IntermediatePaths.size ();
685
675
std::vector<ThreadingPath> PredPaths =
686
- getPathsFromStateDefMap (StateDef, IncomingPhi, VB, PredPathLimit );
676
+ getPathsFromStateDefMap (StateDef, IncomingPhi, VB);
687
677
for (const ThreadingPath &Path : PredPaths) {
688
678
for (const PathType &IPath : IntermediatePaths) {
689
679
ThreadingPath NewPath (Path);
@@ -698,7 +688,7 @@ struct AllSwitchPaths {
698
688
}
699
689
700
690
PathsType paths (BasicBlock *BB, BasicBlock *ToBB, VisitedBlocks &Visited,
701
- unsigned PathDepth, unsigned PathsLimit ) {
691
+ unsigned PathDepth) {
702
692
PathsType Res;
703
693
704
694
// Stop exploring paths after visiting MaxPathLength blocks
@@ -725,8 +715,6 @@ struct AllSwitchPaths {
725
715
// is used to prevent a duplicate path from being generated
726
716
SmallSet<BasicBlock *, 4 > Successors;
727
717
for (BasicBlock *Succ : successors (BB)) {
728
- if (Res.size () >= PathsLimit)
729
- break ;
730
718
if (!Successors.insert (Succ).second )
731
719
continue ;
732
720
@@ -748,12 +736,14 @@ struct AllSwitchPaths {
748
736
// coverage and compile time.
749
737
if (LI->getLoopFor (Succ) != CurrLoop)
750
738
continue ;
751
- assert (PathsLimit > Res.size ());
752
- PathsType SuccPaths =
753
- paths (Succ, ToBB, Visited, PathDepth + 1 , PathsLimit - Res.size ());
739
+
740
+ PathsType SuccPaths = paths (Succ, ToBB, Visited, PathDepth + 1 );
754
741
for (PathType &Path : SuccPaths) {
755
742
Path.push_front (BB);
756
743
Res.push_back (Path);
744
+ if (Res.size () >= MaxNumPaths) {
745
+ return Res;
746
+ }
757
747
}
758
748
}
759
749
// This block could now be visited again from a different predecessor. Note
0 commit comments