Skip to content

Commit fae3493

Browse files
[llvm] Use *Set::insert_range (NFC) (#132591)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch uses insert_range with iterator ranges. For each case, I've verified that foos is defined as make_range(foo_begin(), foo_end()) or in a similar manner.
1 parent 00cb966 commit fae3493

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

llvm/lib/IR/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ Error StructType::checkBody(ArrayRef<Type *> Elements) {
553553
if (Ty == this)
554554
return createStringError(Twine("identified structure type '") +
555555
getName() + "' is recursive");
556-
Worklist.insert(Ty->subtype_begin(), Ty->subtype_end());
556+
Worklist.insert_range(Ty->subtypes());
557557
}
558558
return Error::success();
559559
}

llvm/lib/IR/Verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7215,7 +7215,7 @@ void Verifier::verifyCompileUnits() {
72157215
auto *CUs = M.getNamedMetadata("llvm.dbg.cu");
72167216
SmallPtrSet<const Metadata *, 2> Listed;
72177217
if (CUs)
7218-
Listed.insert(CUs->op_begin(), CUs->op_end());
7218+
Listed.insert_range(CUs->operands());
72197219
for (const auto *CU : CUVisited)
72207220
CheckDI(Listed.count(CU), "DICompileUnit not listed in llvm.dbg.cu", CU);
72217221
CUVisited.clear();

llvm/lib/LTO/LTO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,9 +1439,9 @@ class InProcessThinBackend : public ThinBackendProc {
14391439
AddStream(std::move(AddStream)), Cache(std::move(Cache)),
14401440
ShouldEmitIndexFiles(ShouldEmitIndexFiles) {
14411441
auto &Defs = CombinedIndex.cfiFunctionDefs();
1442-
CfiFunctionDefs.insert(Defs.guid_begin(), Defs.guid_end());
1442+
CfiFunctionDefs.insert_range(Defs.guids());
14431443
auto &Decls = CombinedIndex.cfiFunctionDecls();
1444-
CfiFunctionDecls.insert(Decls.guid_begin(), Decls.guid_end());
1444+
CfiFunctionDecls.insert_range(Decls.guids());
14451445
}
14461446

14471447
virtual Error runThinLTOBackendThread(

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ class LowerMatrixIntrinsics {
19721972
if (CurrI->mayHaveSideEffects() || CurrI->mayReadFromMemory())
19731973
return;
19741974
ToHoist.push_back(CurrI);
1975-
WorkList.insert(CurrI->op_begin(), CurrI->op_end());
1975+
WorkList.insert_range(CurrI->operands());
19761976
}
19771977

19781978
sort(ToHoist, [this](Instruction *A, Instruction *B) {

llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static bool partitionOuterLoopBlocks(
102102
Loop &Root, Loop &JamLoop, BasicBlockSet &JamLoopBlocks,
103103
DenseMap<Loop *, BasicBlockSet> &ForeBlocksMap,
104104
DenseMap<Loop *, BasicBlockSet> &AftBlocksMap, DominatorTree &DT) {
105-
JamLoopBlocks.insert(JamLoop.block_begin(), JamLoop.block_end());
105+
JamLoopBlocks.insert_range(JamLoop.blocks());
106106

107107
for (Loop *L : Root.getLoopsInPreorder()) {
108108
if (L == &JamLoop)
@@ -122,7 +122,7 @@ static bool partitionOuterLoopBlocks(Loop *L, Loop *SubLoop,
122122
BasicBlockSet &SubLoopBlocks,
123123
BasicBlockSet &AftBlocks,
124124
DominatorTree *DT) {
125-
SubLoopBlocks.insert(SubLoop->block_begin(), SubLoop->block_end());
125+
SubLoopBlocks.insert_range(SubLoop->blocks());
126126
return partitionLoopBlocks(*L, ForeBlocks, AftBlocks, *DT);
127127
}
128128

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
701701
// otherwise our loop iterators won't work.
702702

703703
SmallPtrSet<BasicBlock *, 8> blocks;
704-
blocks.insert(L->block_begin(), L->block_end());
704+
blocks.insert_range(L->blocks());
705705
for (BasicBlock *BB : blocks)
706706
LI->removeBlock(BB);
707707

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ void InnerLoopVectorizer::sinkScalarOperands(Instruction *PredInst) {
29702970
// may have failed to sink I's operands (recursively), which we try
29712971
// (again) here.
29722972
if (I->getParent() == PredBB) {
2973-
Worklist.insert(I->op_begin(), I->op_end());
2973+
Worklist.insert_range(I->operands());
29742974
continue;
29752975
}
29762976

@@ -2985,7 +2985,7 @@ void InnerLoopVectorizer::sinkScalarOperands(Instruction *PredInst) {
29852985
// Move the instruction to the beginning of the predicated block, and add
29862986
// it's operands to the worklist.
29872987
I->moveBefore(PredBB->getFirstInsertionPt());
2988-
Worklist.insert(I->op_begin(), I->op_end());
2988+
Worklist.insert_range(I->operands());
29892989

29902990
// The sinking may have enabled other instructions to be sunk, so we will
29912991
// need to iterate.

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
582582
if (isa<VPHeaderPHIRecipe>(Cur))
583583
continue;
584584
for (VPValue *V : Cur->definedValues())
585-
Users.insert(V->user_begin(), V->user_end());
585+
Users.insert_range(V->users());
586586
}
587587
return Users.takeVector();
588588
}

0 commit comments

Comments
 (0)