[PATCH] D25891: [llvm] Convert iterable SmallPtrSet's to SmallSetVector's in Codegen

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 12:03:09 PDT 2016

rnk added a comment.

I don't think we should have a blanket rule banning iteration of unordered sets. Some of these do look like bugs, though. I think we should probably consider perturbing (maybe randomizing?) iteration order in NDEBUG builds to shake out these kinds of bugs.

Comment at: lib/CodeGen/CodeGenPrepare.cpp:320-321
     while (!WorkList.empty()) {
       BasicBlock *BB = *WorkList.begin();
-      WorkList.erase(BB);
+      WorkList.remove(BB);
       SmallVector<BasicBlock*, 2> Successors(succ_begin(BB), succ_end(BB));
This change makes this loop O(n^2), which is not acceptable.

Comment at: lib/CodeGen/MachineVerifier.cpp:1460-1461
   // Iteratively push vregsPassed to successors. This will converge to the same
   // final state regardless of DenseSet iteration order.
   while (!todo.empty()) {
There is a comment here suggesting that iteration order truly doesn't matter.



More information about the llvm-commits mailing list