diff options
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 997e6ef04ca..6a6900f2cc6 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -883,9 +883,13 @@ static BasicBlock *buildClonedLoopBlocks( PN.removeIncomingValue(LoopBB, /*DeletePHIIfEmpty*/ false); // Record the domtree updates for the new blocks. - for (auto *ClonedBB : NewBlocks) + SmallPtrSet<BasicBlock *, 4> SuccSet; + for (auto *ClonedBB : NewBlocks) { for (auto *SuccBB : successors(ClonedBB)) - DTUpdates.push_back({DominatorTree::Insert, ClonedBB, SuccBB}); + if (SuccSet.insert(SuccBB).second) + DTUpdates.push_back({DominatorTree::Insert, ClonedBB, SuccBB}); + SuccSet.clear(); + } return ClonedPH; } |