[LAA] Hold bounds via ValueHandles during SCEV expansion
[oota-llvm.git] / lib / Analysis / LoopAccessAnalysis.cpp
index 41499df43cc3ccb23204e74f54491851a06dd017..87dd8d47a65581ec761e7a9f57c6368405efeae7 100644 (file)
@@ -1593,10 +1593,13 @@ static Instruction *getFirstInst(Instruction *FirstInst, Value *V,
   return nullptr;
 }
 
-/// \brief IR Values for the lower and upper bounds of a pointer evolution.
+/// \brief IR Values for the lower and upper bounds of a pointer evolution.  We
+/// need to use value-handles because SCEV expansion can invalidate previously
+/// expanded values.  Thus expansion of a pointer can invalidate the bounds for
+/// a previous one.
 struct PointerBounds {
-  Value *Start;
-  Value *End;
+  TrackingVH<Value> Start;
+  TrackingVH<Value> End;
 };
 
 /// \brief Expand code for the lower and upper bound of the pointer group \p CG