From 1c55dcbca71d2df2fee4564ad53b62505fdbb819 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Thu, 25 Mar 2021 22:58:10 +0300 Subject: [NFCI][SimplifyCFG] Don't pay for a Small{Map,Set}Vector when plain SmallSet will suffice This *only* changes the cases where we *really* don't care about the iteration order of the underlying contained, namely when we will use the values from it to form DTU updates. --- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp') diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index d1a3ae5..2d5f1dd 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -228,8 +228,7 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU, // These dominator edges will be redirected from Pred. std::vector Updates; if (DTU) { - SmallSetVector UniqueSuccessors(succ_begin(BB), - succ_end(BB)); + SmallPtrSet UniqueSuccessors(succ_begin(BB), succ_end(BB)); Updates.reserve(1 + (2 * UniqueSuccessors.size())); // Add insert edges first. Experimentally, for the particular case of two // blocks that can be merged, with a single successor and single predecessor @@ -569,8 +568,8 @@ static BasicBlock *SplitBlockImpl(BasicBlock *Old, Instruction *SplitPt, if (DTU) { SmallVector Updates; // Old dominates New. New node dominates all other nodes dominated by Old. - SmallSetVector UniqueSuccessorsOfOld(succ_begin(New), - succ_end(New)); + SmallPtrSet UniqueSuccessorsOfOld(succ_begin(New), + succ_end(New)); Updates.push_back({DominatorTree::Insert, Old, New}); Updates.reserve(Updates.size() + 2 * UniqueSuccessorsOfOld.size()); for (BasicBlock *UniqueSuccessorOfOld : UniqueSuccessorsOfOld) { @@ -635,8 +634,8 @@ BasicBlock *llvm::splitBlockBefore(BasicBlock *Old, Instruction *SplitPt, SmallVector DTUpdates; // New dominates Old. The predecessor nodes of the Old node dominate // New node. - SmallSetVector UniquePredecessorsOfOld(pred_begin(New), - pred_end(New)); + SmallPtrSet UniquePredecessorsOfOld(pred_begin(New), + pred_end(New)); DTUpdates.push_back({DominatorTree::Insert, New, Old}); DTUpdates.reserve(DTUpdates.size() + 2 * UniquePredecessorsOfOld.size()); for (BasicBlock *UniquePredecessorOfOld : UniquePredecessorsOfOld) { @@ -675,7 +674,7 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB, } else { // Split block expects NewBB to have a non-empty set of predecessors. SmallVector Updates; - SmallSetVector UniquePreds(Preds.begin(), Preds.end()); + SmallPtrSet UniquePreds(Preds.begin(), Preds.end()); Updates.push_back({DominatorTree::Insert, NewBB, OldBB}); Updates.reserve(Updates.size() + 2 * UniquePreds.size()); for (auto *UniquePred : UniquePreds) { @@ -1141,8 +1140,8 @@ SplitBlockAndInsertIfThenImpl(Value *Cond, Instruction *SplitBefore, BasicBlock *Head = SplitBefore->getParent(); BasicBlock *Tail = Head->splitBasicBlock(SplitBefore->getIterator()); if (DTU) { - SmallSetVector UniqueSuccessorsOfHead(succ_begin(Tail), - succ_end(Tail)); + SmallPtrSet UniqueSuccessorsOfHead(succ_begin(Tail), + succ_end(Tail)); Updates.push_back({DominatorTree::Insert, Head, Tail}); Updates.reserve(Updates.size() + 2 * UniqueSuccessorsOfHead.size()); for (BasicBlock *UniqueSuccessorOfHead : UniqueSuccessorsOfHead) { -- cgit v1.1