[PATCH] D23396: [Assumptions] Make collecting ephemeral values not quadratic in the number of assume intrinsics.

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 22:56:29 PDT 2016


hfinkel added inline comments.

================
Comment at: lib/Analysis/CodeMetrics.cpp:54
@@ +53,3 @@
+  // worklist forever.
+  for (int i = 0; i < (int)Worklist.size(); ++i) {
+    const Value *V = Worklist[i];
----------------
chandlerc wrote:
> hfinkel wrote:
> > Is there a reason to use the index here? Why not write this as:
> > 
> >   for (auto I = Worklist.begin(); I != Worklist.end(); ++I) {
> >     const Value *V = *I;
> > 
> Because that isn't valid.
> 
> When you grow the worklist you invalidate all iterators (because the iterators are just pointers and its a vector that may have to re-allocate).
Ah, right ;) -- Why don't we use a std::deque for these things?


https://reviews.llvm.org/D23396





More information about the llvm-commits mailing list