@@ -393,12 +393,10 @@ bool AVarBoundsInfo::addAssignment(BoundsKey L, BoundsKey R) {
393
393
// dependency and never will be able to find the bounds for the return
394
394
// value.
395
395
if (L != R)
396
- ProgVarGraph.addUniqueEdge (R, L);
396
+ ProgVarGraph.addEdge (R, L);
397
397
} else {
398
- ProgVarGraph.addUniqueEdge (R, L);
399
- ProgramVar *PV = getProgramVar (R);
400
- if (!(PV && PV->IsNumConstant ()))
401
- ProgVarGraph.addUniqueEdge (L, R);
398
+ ProgVarGraph.addEdge (L, R);
399
+ ProgVarGraph.addEdge (R, L);
402
400
}
403
401
return true ;
404
402
}
@@ -714,45 +712,7 @@ bool AvarBoundsInference::inferPossibleBounds(BoundsKey K, ABounds *SB,
714
712
}
715
713
}
716
714
717
- // All constants are reachable!
718
- if (SBVar->IsNumConstant ()) {
719
- PotK.insert (FromVarK);
720
- }
721
-
722
- // Get all bounds key that are equivalent to FromVarK
723
- std::set<BoundsKey> AllFKeys;
724
- AllFKeys.clear ();
725
- AllFKeys.insert (FromVarK);
726
-
727
- for (auto CurrVarK : AllFKeys) {
728
- // Find all the in scope variables reachable from the CurrVarK
729
- // bounds variable.
730
- ScopeVisitor TV (DstScope, PotK, BI->PVarInfo ,
731
- BI->PointerBoundsKey );
732
- BKGraph.visitBreadthFirst (CurrVarK, [&TV](BoundsKey BK) {
733
- TV.visitBoundsKey (BK);
734
- });
735
- }
736
-
737
- // This is to get all the constants that are assigned to the variables
738
- // reachable from FromVarK.
739
- if (!SBVar->IsNumConstant ()) {
740
- std::set<BoundsKey> ReachableCons;
741
- std::set<BoundsKey> Pre;
742
- for (auto CK : PotK) {
743
- Pre.clear ();
744
- BKGraph.getPredecessors (CK, Pre);
745
- for (auto T : Pre) {
746
- auto *TVar = BI->getProgramVar (T);
747
- if (TVar->IsNumConstant ()) {
748
- ReachableCons.insert (T);
749
- }
750
- }
751
- }
752
- PotK.insert (ReachableCons.begin (), ReachableCons.end ());
753
- }
754
-
755
- return !PotK.empty ();
715
+ return RetVal;
756
716
}
757
717
758
718
bool AvarBoundsInference::getRelevantBounds (std::set<BoundsKey> &RBKeys,
@@ -1105,10 +1065,11 @@ bool AVarBoundsInfo::performFlowAnalysis(ProgramInfo *PI) {
1105
1065
// Any thing changed? which means bounds of a variable changed
1106
1066
// Which means we need to recompute the flow based bounds for
1107
1067
// all arrays that have flow based bounds.
1108
- keepHighestPriorityBounds (ArrPointerBoundsKey);
1109
- // Remove flow inferred bounds, if exist for all the array pointers.
1110
- for (auto TBK : ArrPointerBoundsKey)
1111
- removeBounds (TBK, FlowInferred);
1068
+ if (keepHighestPriorityBounds (ArrPointerBoundsKey)) {
1069
+ // Remove flow inferred bounds, if exist for all the array pointers.
1070
+ for (auto TBK : ArrPointerBoundsKey)
1071
+ removeBounds (TBK, FlowInferred);
1072
+ }
1112
1073
1113
1074
// Next, get the ARR pointers that has bounds.
1114
1075
// These are pointers with bounds.
0 commit comments