@@ -1114,17 +1114,25 @@ static bool DependenceMightRace(
1114
1114
DT.findNearestCommonDominator (Src->getParent (), Dst->getParent ()));
1115
1115
// Find the loop depth of that spindle.
1116
1116
unsigned MaxLoopDepthToCheck = LI.getLoopDepth (DomSpindle->getEntry ());
1117
+ // It's possible that Src or Dst appears to have a smaller loop depth than the
1118
+ // entry of DomSpindle. For example, LoopInfo might not consider Src or Dst
1119
+ // part of a loop if they belong to blocks terminated by unreachable.
1120
+ if (MaxLoopDepthToCheck > LI.getLoopDepth (Src->getParent ()))
1121
+ MaxLoopDepthToCheck = LI.getLoopDepth (Src->getParent ());
1122
+ if (MaxLoopDepthToCheck > LI.getLoopDepth (Dst->getParent ()))
1123
+ MaxLoopDepthToCheck = LI.getLoopDepth (Dst->getParent ());
1124
+
1125
+ // Check if dependence does not depend on looping.
1126
+ if (0 == MaxLoopDepthToCheck)
1127
+ // If there's no loop to worry about, then the existence of the dependence
1128
+ // implies the potential for a race.
1129
+ return true ;
1130
+
1117
1131
assert (MinObjDepth <= MaxLoopDepthToCheck &&
1118
1132
" Minimum loop depth of underlying object cannot be greater "
1119
1133
" than maximum loop depth of dependence." );
1120
1134
1121
1135
if (MaxLoopDepthToCheck == MinObjDepth) {
1122
- // Dependence does not depend on looping.
1123
- if (!MaxLoopDepthToCheck)
1124
- // If there's no loop to worry about, then the existence of the dependence
1125
- // implies the potential for a race.
1126
- return true ;
1127
-
1128
1136
if (TI.getTaskFor (Src->getParent ()) == TI.getTaskFor (Dst->getParent ()))
1129
1137
return false ;
1130
1138
0 commit comments