================
@@ -1866,10 +1866,18 @@ bool 
SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
   // If either of the blocks has it's address taken, then we can't do this 
fold,
   // because the code we'd hoist would no longer run when we jump into the 
block
   // by it's address.
+  SmallVector<BasicBlock *, 4> UniqSuccessors;
+  UniqSuccessors.reserve(BB->getTerminator()->getNumSuccessors());
   for (auto *Succ : successors(BB)) {
     if (Succ->hasAddressTaken())
       return false;
-    if (Succ->getSinglePredecessor())
+    // Collect all unique successors, using vec instead of set to preserve
+    // order.
+    if (find(UniqSuccessors, Succ) == UniqSuccessors.end())
----------------
Camsyn wrote:

I think that there are not too many succs usually, and thus vec might be more 
efficient than using a setvec, as a set introduces extra overhead. 

https://github.com/llvm/llvm-project/pull/165700
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to