Skip to content

Commit 1b189ca

Browse files
[llvm] Use *Set::insert_range (NFC) (#132509)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch uses insert_range in conjunction with llvm::{predecessors,successors} and MachineBasicBlock::{predecessors,successors}.
1 parent c6c3946 commit 1b189ca

12 files changed

+17
-17
lines changed

llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ FunctionPropertiesUpdater::FunctionPropertiesUpdater(
324324
// The successors may become unreachable in the case of `invoke` inlining.
325325
// We track successors separately, too, because they form a boundary, together
326326
// with the CB BB ('Entry') between which the inlined callee will be pasted.
327-
Successors.insert(succ_begin(&CallSiteBB), succ_end(&CallSiteBB));
327+
Successors.insert_range(successors(&CallSiteBB));
328328

329329
// the outcome of the inlining may be that some edges get lost (DCEd BBs
330330
// because inlining brought some constant, for example). We don't know which
@@ -349,7 +349,7 @@ FunctionPropertiesUpdater::FunctionPropertiesUpdater(
349349
// discounted BBs will be checked if reachable and re-added.
350350
if (const auto *II = dyn_cast<InvokeInst>(&CB)) {
351351
const auto *UnwindDest = II->getUnwindDest();
352-
Successors.insert(succ_begin(UnwindDest), succ_end(UnwindDest));
352+
Successors.insert_range(successors(UnwindDest));
353353
// Same idea as above, we pretend we lose all these edges.
354354
for (auto *Succ : successors(UnwindDest))
355355
if (Inserted.insert(Succ).second)
@@ -454,7 +454,7 @@ void FunctionPropertiesUpdater::finish(FunctionAnalysisManager &FAM) const {
454454
const auto *BB = Reinclude[I];
455455
FPI.reIncludeBB(*BB);
456456
if (I >= IncludeSuccessorsMark)
457-
Reinclude.insert(succ_begin(BB), succ_end(BB));
457+
Reinclude.insert_range(successors(BB));
458458
}
459459

460460
// For exclusion, we don't need to exclude the set of BBs that were successors

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ bool CodeGenPrepare::canMergeBlocks(const BasicBlock *BB,
10821082
for (unsigned i = 0, e = BBPN->getNumIncomingValues(); i != e; ++i)
10831083
BBPreds.insert(BBPN->getIncomingBlock(i));
10841084
} else {
1085-
BBPreds.insert(pred_begin(BB), pred_end(BB));
1085+
BBPreds.insert_range(predecessors(BB));
10861086
}
10871087

10881088
// Walk the preds of DestBB.

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,11 @@ void MachineVerifier::visitMachineFunctionBefore() {
708708
FunctionBlocks.insert(&MBB);
709709
BBInfo &MInfo = MBBInfoMap[&MBB];
710710

711-
MInfo.Preds.insert(MBB.pred_begin(), MBB.pred_end());
711+
MInfo.Preds.insert_range(MBB.predecessors());
712712
if (MInfo.Preds.size() != MBB.pred_size())
713713
report("MBB has duplicate entries in its predecessor list.", &MBB);
714714

715-
MInfo.Succs.insert(MBB.succ_begin(), MBB.succ_end());
715+
MInfo.Succs.insert_range(MBB.successors());
716716
if (MInfo.Succs.size() != MBB.succ_size())
717717
report("MBB has duplicate entries in its successor list.", &MBB);
718718
}

llvm/lib/CodeGen/TailDuplicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB,
878878
if (CandidatePtr)
879879
Preds.insert_range(*CandidatePtr);
880880
else
881-
Preds.insert(TailBB->pred_begin(), TailBB->pred_end());
881+
Preds.insert_range(TailBB->predecessors());
882882

883883
for (MachineBasicBlock *PredBB : Preds) {
884884
assert(TailBB != PredBB &&

llvm/lib/IR/SafepointIRVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ void GCPtrTracker::recalculateBBsStates() {
646646
transferBlock(BB, *BBS, ContributionChanged);
647647
if (OldOutCount != BBS->AvailableOut.size()) {
648648
assert(OldOutCount > BBS->AvailableOut.size() && "invariant!");
649-
Worklist.insert(succ_begin(BB), succ_end(BB));
649+
Worklist.insert_range(successors(BB));
650650
}
651651
}
652652
}

llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class AMDGPUInsertDelayAlu {
466466
auto &MBB = *WorkList.pop_back_val();
467467
bool Changed = runOnMachineBasicBlock(MBB, false);
468468
if (Changed)
469-
WorkList.insert(MBB.succ_begin(), MBB.succ_end());
469+
WorkList.insert_range(MBB.successors());
470470
}
471471

472472
LLVM_DEBUG(dbgs() << "Final pass over all BBs\n");

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11045,7 +11045,7 @@ void ARMTargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
1104511045
SmallVectorImpl<MachineBasicBlock*> &MBBList = CallSiteNumToLPad[I];
1104611046
for (MachineBasicBlock *MBB : MBBList) {
1104711047
LPadList.push_back(MBB);
11048-
InvokeBBs.insert(MBB->pred_begin(), MBB->pred_end());
11048+
InvokeBBs.insert_range(MBB->predecessors());
1104911049
}
1105011050
}
1105111051

llvm/lib/Target/VE/VEISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ VETargetLowering::emitSjLjDispatchBlock(MachineInstr &MI,
24122412
for (unsigned CSI = 1; CSI <= MaxCSNum; ++CSI) {
24132413
for (auto &LP : CallSiteNumToLPad[CSI]) {
24142414
LPadList.push_back(LP);
2415-
InvokeBBs.insert(LP->pred_begin(), LP->pred_end());
2415+
InvokeBBs.insert_range(LP->predecessors());
24162416
}
24172417
}
24182418

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37269,7 +37269,7 @@ X86TargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
3726937269
for (unsigned CSI = 1; CSI <= MaxCSNum; ++CSI) {
3727037270
for (auto &LP : CallSiteNumToLPad[CSI]) {
3727137271
LPadList.push_back(LP);
37272-
InvokeBBs.insert(LP->pred_begin(), LP->pred_end());
37272+
InvokeBBs.insert_range(LP->predecessors());
3727337273
}
3727437274
}
3727537275

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ class ControlFlowHoister {
689689
// TODO: This could be expanded to allowing branches where both ends
690690
// eventually converge to a single block.
691691
SmallPtrSet<BasicBlock *, 4> TrueDestSucc, FalseDestSucc;
692-
TrueDestSucc.insert(succ_begin(TrueDest), succ_end(TrueDest));
693-
FalseDestSucc.insert(succ_begin(FalseDest), succ_end(FalseDest));
692+
TrueDestSucc.insert_range(successors(TrueDest));
693+
FalseDestSucc.insert_range(successors(FalseDest));
694694
BasicBlock *CommonSucc = nullptr;
695695
if (TrueDestSucc.count(FalseDest)) {
696696
CommonSucc = FalseDest;

llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,7 +3302,7 @@ static void computeLiveInValues(DominatorTree &DT, Function &F,
33023302
Data.LiveIn[&BB].set_union(Data.LiveOut[&BB]);
33033303
Data.LiveIn[&BB].set_subtract(Data.KillSet[&BB]);
33043304
if (!Data.LiveIn[&BB].empty())
3305-
Worklist.insert(pred_begin(&BB), pred_end(&BB));
3305+
Worklist.insert_range(predecessors(&BB));
33063306
}
33073307

33083308
// Propagate that liveness until stable
@@ -3336,7 +3336,7 @@ static void computeLiveInValues(DominatorTree &DT, Function &F,
33363336
// assert: OldLiveIn is a subset of LiveTmp
33373337
if (OldLiveIn.size() != LiveTmp.size()) {
33383338
Data.LiveIn[BB] = LiveTmp;
3339-
Worklist.insert(pred_begin(BB), pred_end(BB));
3339+
Worklist.insert_range(predecessors(BB));
33403340
}
33413341
} // while (!Worklist.empty())
33423342

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ void llvm::SplitBlockAndInsertIfThenElse(
16601660
SmallPtrSet<BasicBlock *, 8> UniqueOrigSuccessors;
16611661
BasicBlock *Head = SplitBefore->getParent();
16621662
if (DTU) {
1663-
UniqueOrigSuccessors.insert(succ_begin(Head), succ_end(Head));
1663+
UniqueOrigSuccessors.insert_range(successors(Head));
16641664
Updates.reserve(4 + 2 * UniqueOrigSuccessors.size());
16651665
}
16661666

0 commit comments

Comments
 (0)