diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 08005c198298..6d5a68214e7c 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1099,7 +1099,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI, ++NumFoldValueComparisonIntoPredecessors; }); - SmallVector Preds(predecessors(BB)); + SmallSetVector Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.pop_back_val(); @@ -1260,6 +1260,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(Instruction *TI, // Okay, at this point, we know which new successor Pred will get. Make // sure we update the number of entries in the PHI nodes for these // successors. + assert(!NewSuccessors.empty() && "Should be adding some new successors."); for (const std::pair &NewSuccessor : NewSuccessors) { for (auto I : seq(0, NewSuccessor.second)) {