Skip to content

Commit cde58bf

Browse files
[Transforms] Use range constructors of *Set (NFC) (#133203)
1 parent ba1d901 commit cde58bf

15 files changed

+26
-31
lines changed

llvm/lib/Transforms/IPO/ExtractGV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void makeVisible(GlobalValue &GV, bool Delete) {
5252
/// global values specified.
5353
ExtractGVPass::ExtractGVPass(std::vector<GlobalValue *> &GVs, bool deleteS,
5454
bool keepConstInit)
55-
: Named(GVs.begin(), GVs.end()), deleteStuff(deleteS),
55+
: Named(llvm::from_range, GVs), deleteStuff(deleteS),
5656
keepConstInit(keepConstInit) {}
5757

5858
PreservedAnalyses ExtractGVPass::run(Module &M, ModuleAnalysisManager &) {

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,10 +2319,10 @@ class LLVMUsed {
23192319
LLVMUsed(Module &M) {
23202320
SmallVector<GlobalValue *, 4> Vec;
23212321
UsedV = collectUsedGlobalVariables(M, Vec, false);
2322-
Used = {Vec.begin(), Vec.end()};
2322+
Used = {llvm::from_range, Vec};
23232323
Vec.clear();
23242324
CompilerUsedV = collectUsedGlobalVariables(M, Vec, true);
2325-
CompilerUsed = {Vec.begin(), Vec.end()};
2325+
CompilerUsed = {llvm::from_range, Vec};
23262326
}
23272327

23282328
using iterator = SmallPtrSet<GlobalValue *, 4>::iterator;

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5874,7 +5874,7 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C,
58745874
bool PostLink = LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
58755875
LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink ||
58765876
LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink;
5877-
SetVector<Function *> Functions(SCC.begin(), SCC.end());
5877+
SetVector<Function *> Functions(llvm::from_range, SCC);
58785878
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
58795879
/*CGSCC*/ &Functions, PostLink);
58805880

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,8 +1591,7 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
15911591
// that we only have to insert *one* load (which means we're basically moving
15921592
// the load, not inserting a new one).
15931593

1594-
SmallPtrSet<BasicBlock *, 4> Blockers(UnavailableBlocks.begin(),
1595-
UnavailableBlocks.end());
1594+
SmallPtrSet<BasicBlock *, 4> Blockers(llvm::from_range, UnavailableBlocks);
15961595

15971596
// Let's find the first basic block with more than one predecessor. Walk
15981597
// backwards through predecessors if needed.

llvm/lib/Transforms/Scalar/GVNSink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class GVNSink {
522522

523523
unsigned NumSunk = 0;
524524
ReversePostOrderTraversal<Function*> RPOT(&F);
525-
VN.setReachableBBs(BasicBlocksSet(RPOT.begin(), RPOT.end()));
525+
VN.setReachableBBs(BasicBlocksSet(llvm::from_range, RPOT));
526526
// Populate reverse post-order to order basic blocks in deterministic
527527
// order. Any arbitrary ordering will work in this case as long as they are
528528
// deterministic. The node ordering of newly created basic blocks

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ void InferAddressSpacesImpl::inferAddressSpaces(
895895
ArrayRef<WeakTrackingVH> Postorder,
896896
ValueToAddrSpaceMapTy &InferredAddrSpace,
897897
PredicatedAddrSpaceMapTy &PredicatedAS) const {
898-
SetVector<Value *> Worklist(Postorder.begin(), Postorder.end());
898+
SetVector<Value *> Worklist(llvm::from_range, Postorder);
899899
// Initially, all expressions are in the uninitialized address space.
900900
for (Value *V : Postorder)
901901
InferredAddrSpace[V] = UninitializedAddressSpace;

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,7 @@ static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT,
15641564
#ifndef NDEBUG
15651565
SmallVector<BasicBlock *, 32> ExitBlocks;
15661566
CurLoop->getUniqueExitBlocks(ExitBlocks);
1567-
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
1568-
ExitBlocks.end());
1567+
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
15691568
#endif
15701569
BasicBlock *ExitBB = PN->getParent();
15711570
assert(ExitBlockSet.count(ExitBB) && "Expect the PHI is in an exit block.");
@@ -1699,8 +1698,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
16991698
#ifndef NDEBUG
17001699
SmallVector<BasicBlock *, 32> ExitBlocks;
17011700
CurLoop->getUniqueExitBlocks(ExitBlocks);
1702-
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
1703-
ExitBlocks.end());
1701+
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
17041702
#endif
17051703

17061704
// Clones of this instruction. Don't create more than one per exit block!

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
102102
bool KeepOneInputPHIs) {
103103
#ifndef NDEBUG
104104
// Make sure that all predecessors of each dead block is also dead.
105-
SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
105+
SmallPtrSet<BasicBlock *, 4> Dead(llvm::from_range, BBs);
106106
assert(Dead.size() == BBs.size() && "Duplicating blocks?");
107107
for (auto *BB : Dead)
108108
for (BasicBlock *Pred : predecessors(BB))
@@ -1261,7 +1261,7 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
12611261
ArrayRef<BasicBlock *> Preds, BranchInst *BI,
12621262
bool HasLoopExit) {
12631263
// Otherwise, create a new PHI node in NewBB for each PHI node in OrigBB.
1264-
SmallPtrSet<BasicBlock *, 16> PredSet(Preds.begin(), Preds.end());
1264+
SmallPtrSet<BasicBlock *, 16> PredSet(llvm::from_range, Preds);
12651265
for (BasicBlock::iterator I = OrigBB->begin(); isa<PHINode>(I); ) {
12661266
PHINode *PN = cast<PHINode>(I++);
12671267

llvm/lib/Transforms/Utils/InjectTLIMappings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
8787
SmallVector<std::string, 8> Mappings;
8888
VFABI::getVectorVariantNames(CI, Mappings);
8989
Module *M = CI.getModule();
90-
const SetVector<StringRef> OriginalSetOfMappings(Mappings.begin(),
91-
Mappings.end());
90+
const SetVector<StringRef> OriginalSetOfMappings(llvm::from_range, Mappings);
9291

9392
auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
9493
const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ void PromoteMem2Reg::run() {
815815
AllocaLookup[Allocas[AllocaNum]] = AllocaNum;
816816

817817
// Unique the set of defining blocks for efficient lookup.
818-
SmallPtrSet<BasicBlock *, 32> DefBlocks(Info.DefiningBlocks.begin(),
819-
Info.DefiningBlocks.end());
818+
SmallPtrSet<BasicBlock *, 32> DefBlocks(llvm::from_range,
819+
Info.DefiningBlocks);
820820

821821
// Determine which blocks the value is live in. These are blocks which lead
822822
// to uses.

0 commit comments

Comments
 (0)