Skip to content

[Transforms] Construct SmallVector with iterator ranges (NFC) #136259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/IPO/ExpandVariadics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,7 @@ ExpandVariadics::defineVariadicWrapper(Module &M, IRBuilder<> &Builder,
Builder.CreateIntrinsic(Intrinsic::vastart, {DL.getAllocaPtrType(Ctx)},
{VaListInstance});

SmallVector<Value *> Args;
for (Argument &A : F.args())
Args.push_back(&A);
SmallVector<Value *> Args(llvm::make_pointer_range(F.args()));

Type *ParameterType = ABI->vaListParameterType(M);
if (ABI->vaListPassedInSSARegister())
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,9 +1740,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
OptimizationRemarkEmitter &ORE) {
bool Changed = false;
DT.updateDFSNumbers();
SmallVector<Value *> FunctionArgs;
for (Value &Arg : F.args())
FunctionArgs.push_back(&Arg);
SmallVector<Value *> FunctionArgs(llvm::make_pointer_range(F.args()));
ConstraintInfo Info(F.getDataLayout(), FunctionArgs);
State S(DT, LI, SE);
std::unique_ptr<Module> ReproducerModule(
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,8 @@ bool IndVarSimplify::simplifyAndExtend(Loop *L,
L->getBlocks()[0]->getModule(), Intrinsic::experimental_guard);
bool HasGuards = GuardDecl && !GuardDecl->use_empty();

SmallVector<PHINode *, 8> LoopPhis;
for (PHINode &PN : L->getHeader()->phis())
LoopPhis.push_back(&PN);
SmallVector<PHINode *, 8> LoopPhis(
llvm::make_pointer_range(L->getHeader()->phis()));

// Each round of simplification iterates through the SimplifyIVUsers worklist
// for all current phis, then determines whether any IVs can be
Expand Down
10 changes: 4 additions & 6 deletions llvm/lib/Transforms/Scalar/LoopInterchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,13 +1574,11 @@ static void moveLCSSAPhis(BasicBlock *InnerExit, BasicBlock *InnerHeader,
P.eraseFromParent();
}

SmallVector<PHINode *, 8> LcssaInnerExit;
for (PHINode &P : InnerExit->phis())
LcssaInnerExit.push_back(&P);
SmallVector<PHINode *, 8> LcssaInnerExit(
llvm::make_pointer_range(InnerExit->phis()));

SmallVector<PHINode *, 8> LcssaInnerLatch;
for (PHINode &P : InnerLatch->phis())
LcssaInnerLatch.push_back(&P);
SmallVector<PHINode *, 8> LcssaInnerLatch(
llvm::make_pointer_range(InnerLatch->phis()));

// Lcssa PHIs for values used outside the inner loop are in InnerExit.
// If a PHI node has users outside of InnerExit, it has a use outside the
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ class ConstantTerminatorFoldingImpl {
for (BasicBlock *BB : DeadExitBlocks) {
// Eliminate all Phis and LandingPads from dead exits.
// TODO: Consider removing all instructions in this dead block.
SmallVector<Instruction *, 4> DeadInstructions;
for (auto &PN : BB->phis())
DeadInstructions.push_back(&PN);
SmallVector<Instruction *, 4> DeadInstructions(
llvm::make_pointer_range(BB->phis()));

if (auto *LandingPad = dyn_cast<LandingPadInst>(BB->getFirstNonPHIIt()))
DeadInstructions.emplace_back(LandingPad);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ bool llvm::DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI,
MemorySSAUpdater *MSSAU) {
// Recursively deleting a PHI may cause multiple PHIs to be deleted
// or RAUW'd undef, so use an array of WeakTrackingVH for the PHIs to delete.
SmallVector<WeakTrackingVH, 8> PHIs;
for (PHINode &PN : BB->phis())
PHIs.push_back(&PN);
SmallVector<WeakTrackingVH, 8> PHIs(llvm::make_pointer_range(BB->phis()));

bool Changed = false;
for (unsigned i = 0, e = PHIs.size(); i != e; ++i)
Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/Transforms/Utils/CodeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ static bool isBlockValidForExtraction(const BasicBlock &BB,
// don't hoist code that uses another basicblock address, as it's likely to
// lead to unexpected behavior, like cross-function jumps
SmallPtrSet<User const *, 16> Visited;
SmallVector<User const *, 16> ToVisit;

for (Instruction const &Inst : BB)
ToVisit.push_back(&Inst);
SmallVector<User const *, 16> ToVisit(llvm::make_pointer_range(BB));

while (!ToVisit.empty()) {
User const *Curr = ToVisit.pop_back_val();
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,9 +1715,8 @@ SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
const TargetTransformInfo *TTI) {
// Find integer phis in order of increasing width.
SmallVector<PHINode*, 8> Phis;
for (PHINode &PN : L->getHeader()->phis())
Phis.push_back(&PN);
SmallVector<PHINode *, 8> Phis(
llvm::make_pointer_range(L->getHeader()->phis()));

if (TTI)
// Use stable_sort to preserve order of equivalent PHIs, so the order
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8267,9 +8267,8 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton() {
// The vec.epilog.iter.check block may contain Phi nodes from inductions or
// reductions which merge control-flow from the latch block and the middle
// block. Update the incoming values here and move the Phi into the preheader.
SmallVector<PHINode *, 4> PhisInBlock;
for (PHINode &Phi : VecEpilogueIterationCountCheck->phis())
PhisInBlock.push_back(&Phi);
SmallVector<PHINode *, 4> PhisInBlock(
llvm::make_pointer_range(VecEpilogueIterationCountCheck->phis()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm:: prefixes should not needed?


for (PHINode *Phi : PhisInBlock) {
Phi->moveBefore(LoopVectorPreHeader->getFirstNonPHIIt());
Expand Down
Loading