Skip to content

Commit

Permalink
Use SmallVectorImpl::iterator/const_iterator instead of SmallVector t…
Browse files Browse the repository at this point in the history
…o avoid specifying the vector size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185540 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Jul 3, 2013
1 parent bf361f5 commit 365ef0b
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion include/llvm/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ namespace llvm {
bool addType(DIType DT);

public:
typedef SmallVector<MDNode *, 8>::const_iterator iterator;
typedef SmallVectorImpl<MDNode *>::const_iterator iterator;
iterator compile_unit_begin() const { return CUs.begin(); }
iterator compile_unit_end() const { return CUs.end(); }
iterator subprogram_begin() const { return SPs.begin(); }
Expand Down
2 changes: 1 addition & 1 deletion lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
// re-generate the operands list. Group the operands by constant scale,
// to avoid multiplying by the same constant scale multiple times.
std::map<APInt, SmallVector<const SCEV *, 4>, APIntCompare> MulOpLists;
for (SmallVector<const SCEV *, 8>::const_iterator I = NewOps.begin(),
for (SmallVectorImpl<const SCEV *>::const_iterator I = NewOps.begin(),
E = NewOps.end(); I != E; ++I)
MulOpLists[M.find(*I)->second].push_back(*I);
// Re-generate the operands list.
Expand Down
12 changes: 6 additions & 6 deletions lib/IR/PassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) {

// Check the immutable passes. Iterate in reverse order so that we find
// the most recently registered passes first.
for (SmallVector<ImmutablePass *, 8>::reverse_iterator I =
for (SmallVectorImpl<ImmutablePass *>::reverse_iterator I =
ImmutablePasses.rbegin(), E = ImmutablePasses.rend(); I != E; ++I) {
AnalysisID PI = (*I)->getPassID();
if (PI == AID)
Expand Down Expand Up @@ -741,8 +741,8 @@ void PMTopLevelManager::dumpPasses() const {
// (sometimes indirectly), but there's no inheritance relationship
// between PMDataManager and Pass, so we have to getAsPass to get
// from a PMDataManager* to a Pass*.
for (SmallVector<PMDataManager *, 8>::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
for (SmallVectorImpl<PMDataManager *>::const_iterator I =
PassManagers.begin(), E = PassManagers.end(); I != E; ++I)
(*I)->getAsPass()->dumpPassStructure(1);
}

Expand All @@ -752,16 +752,16 @@ void PMTopLevelManager::dumpArguments() const {
return;

dbgs() << "Pass Arguments: ";
for (SmallVector<ImmutablePass *, 8>::const_iterator I =
for (SmallVectorImpl<ImmutablePass *>::const_iterator I =
ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
if (const PassInfo *PI =
PassRegistry::getPassRegistry()->getPassInfo((*I)->getPassID())) {
assert(PI && "Expected all immutable passes to be initialized");
if (!PI->isAnalysisGroup())
dbgs() << " -" << PI->getPassArgument();
}
for (SmallVector<PMDataManager *, 8>::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
for (SmallVectorImpl<PMDataManager *>::const_iterator I =
PassManagers.begin(), E = PassManagers.end(); I != E; ++I)
(*I)->dumpPassArguments();
dbgs() << "\n";
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Target/ARM/A15SDOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {
SmallVector<unsigned, 8> Defs = getReadDPRs(MI);
bool Modified = false;

for (SmallVector<unsigned, 8>::iterator I = Defs.begin(), E = Defs.end();
for (SmallVectorImpl<unsigned>::iterator I = Defs.begin(), E = Defs.end();
I != E; ++I) {
// Follow the def-use chain for this DPR through COPYs, and also through
// PHIs (which are essentially multi-way COPYs). It is because of PHIs that
Expand All @@ -630,7 +630,7 @@ bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {

elideCopiesAndPHIs(Def, DefSrcs);

for (SmallVector<MachineInstr*, 8>::iterator II = DefSrcs.begin(),
for (SmallVectorImpl<MachineInstr *>::iterator II = DefSrcs.begin(),
EE = DefSrcs.end(); II != EE; ++II) {
MachineInstr *MI = *II;

Expand All @@ -655,7 +655,7 @@ bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {

if (NewReg != 0) {
Modified = true;
for (SmallVector<MachineOperand*, 8>::const_iterator I = Uses.begin(),
for (SmallVectorImpl<MachineOperand *>::const_iterator I = Uses.begin(),
E = Uses.end(); I != E; ++I) {
DEBUG(dbgs() << "Replacing operand "
<< **I << " with "
Expand Down
4 changes: 2 additions & 2 deletions lib/Target/Mips/MipsDelaySlotFiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ bool MemDefsUses::hasHazard_(const MachineInstr &MI) {

// Check underlying object list.
if (getUnderlyingObjects(MI, Objs)) {
for (SmallVector<const Value *, 4>::const_iterator I = Objs.begin();
for (SmallVectorImpl<const Value *>::const_iterator I = Objs.begin();
I != Objs.end(); ++I)
HasHazard |= updateDefsUses(*I, MI.mayStore());

Expand Down Expand Up @@ -473,7 +473,7 @@ getUnderlyingObjects(const MachineInstr &MI,
SmallVector<Value *, 4> Objs;
GetUnderlyingObjects(const_cast<Value *>(V), Objs);

for (SmallVector<Value*, 4>::iterator I = Objs.begin(), E = Objs.end();
for (SmallVectorImpl<Value *>::iterator I = Objs.begin(), E = Objs.end();
I != E; ++I) {
if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(*I)) {
if (PSV->isAliased(MFI))
Expand Down
2 changes: 1 addition & 1 deletion lib/Target/Mips/MipsISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ namespace llvm {
/// Return pointer to array of integer argument registers.
const uint16_t *intArgRegs() const;

typedef SmallVector<ByValArgInfo, 2>::const_iterator byval_iterator;
typedef SmallVectorImpl<ByValArgInfo>::const_iterator byval_iterator;
byval_iterator byval_begin() const { return ByValArgs.begin(); }
byval_iterator byval_end() const { return ByValArgs.end(); }

Expand Down
24 changes: 12 additions & 12 deletions lib/Target/R600/AMDILCFGStructurizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ class CFGStructurizer {
bool hasBackEdge(BlockT *curBlock);
unsigned getLoopDepth (LoopT *LoopRep);
int countActiveBlock(
typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator IterStart,
typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator IterEnd);
typename SmallVectorImpl<BlockT *>::const_iterator IterStart,
typename SmallVectorImpl<BlockT *>::const_iterator IterEnd);
BlockT *findNearestCommonPostDom(std::set<BlockT *>&);
BlockT *findNearestCommonPostDom(BlockT *Block1, BlockT *Block2);

Expand Down Expand Up @@ -367,7 +367,7 @@ bool CFGStructurizer<PassT>::prepare(FuncT &func, PassT &pass,
// Remove unconditional branch instr.
// Add dummy exit block iff there are multiple returns.

for (typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator
for (typename SmallVectorImpl<BlockT *>::const_iterator
iterBlk = orderedBlks.begin(), iterEndBlk = orderedBlks.end();
iterBlk != iterEndBlk;
++iterBlk) {
Expand Down Expand Up @@ -441,12 +441,12 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
<< ", numRemaintedBlk = " << numRemainedBlk << "\n";
}

typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator
typename SmallVectorImpl<BlockT *>::const_iterator
iterBlk = orderedBlks.begin();
typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator
typename SmallVectorImpl<BlockT *>::const_iterator
iterBlkEnd = orderedBlks.end();

typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator
typename SmallVectorImpl<BlockT *>::const_iterator
sccBeginIter = iterBlk;
BlockT *sccBeginBlk = NULL;
int sccNumBlk = 0; // The number of active blocks, init to a
Expand Down Expand Up @@ -571,7 +571,7 @@ bool CFGStructurizer<PassT>::run(FuncT &func, PassT &pass,
template<class PassT>
void CFGStructurizer<PassT>::printOrderedBlocks(llvm::raw_ostream &os) {
size_t i = 0;
for (typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::const_iterator
for (typename SmallVectorImpl<BlockT *>::const_iterator
iterBlk = orderedBlks.begin(), iterBlkEnd = orderedBlks.end();
iterBlk != iterBlkEnd;
++iterBlk, ++i) {
Expand Down Expand Up @@ -993,7 +993,7 @@ int CFGStructurizer<PassT>::loopcontPatternMatch(LoopT *loopRep,
}
}

for (typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::iterator
for (typename SmallVectorImpl<BlockT *>::iterator
iter = contBlk.begin(), iterEnd = contBlk.end();
iter != iterEnd; ++iter) {
(*iter)->removeSuccessor(loopHeader);
Expand Down Expand Up @@ -2082,7 +2082,7 @@ void CFGStructurizer<PassT>::addDummyExitBlock(SmallVector<BlockT*,
funcRep->push_back(dummyExitBlk); //insert to function
CFGTraits::insertInstrEnd(dummyExitBlk, AMDGPU::RETURN, passRep);

for (typename SmallVector<BlockT *, DEFAULT_VEC_SLOTS>::iterator iter =
for (typename SmallVectorImpl<BlockT *>::iterator iter =
retBlks.begin(),
iterEnd = retBlks.end(); iter != iterEnd; ++iter) {
BlockT *curBlk = *iter;
Expand Down Expand Up @@ -2206,7 +2206,7 @@ CFGStructurizer<PassT>::recordLoopLandBlock(LoopT *loopRep, BlockT *landBlk,
newLandBlk = funcRep->CreateMachineBasicBlock();
funcRep->push_back(newLandBlk); //insert to function
newLandBlk->addSuccessor(landBlk);
for (typename SmallVector<BlockT*, DEFAULT_VEC_SLOTS>::iterator iter =
for (typename SmallVectorImpl<BlockT *>::iterator iter =
inpathBlks.begin(),
iterEnd = inpathBlks.end(); iter != iterEnd; ++iter) {
BlockT *curBlk = *iter;
Expand Down Expand Up @@ -2370,8 +2370,8 @@ unsigned CFGStructurizer<PassT>::getLoopDepth(LoopT *loopRep) {

template<class PassT>
int CFGStructurizer<PassT>::countActiveBlock
(typename SmallVector<BlockT*, DEFAULT_VEC_SLOTS>::const_iterator iterStart,
typename SmallVector<BlockT*, DEFAULT_VEC_SLOTS>::const_iterator iterEnd) {
(typename SmallVectorImpl<BlockT *>::const_iterator iterStart,
typename SmallVectorImpl<BlockT *>::const_iterator iterEnd) {
int count = 0;
while (iterStart != iterEnd) {
if (!isRetiredBlock(*iterStart)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8837,7 +8837,7 @@ SDValue X86TargetLowering::LowerVectorAllZeroTest(SDValue Op,
Opnds.push_back(N->getOperand(1));

for (unsigned Slot = 0, e = Opnds.size(); Slot < e; ++Slot) {
SmallVector<SDValue, 8>::const_iterator I = Opnds.begin() + Slot;
SmallVectorImpl<SDValue>::const_iterator I = Opnds.begin() + Slot;
// BFS traverse all OR'd operands.
if (I->getOpcode() == ISD::OR) {
Opnds.push_back(I->getOperand(0));
Expand Down
2 changes: 1 addition & 1 deletion lib/Transforms/Scalar/MemCpyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Instruction *MemCpyOpt::tryMergingIntoMemset(Instruction *StartInst,
AMemSet->setDebugLoc(Range.TheStores[0]->getDebugLoc());

// Zap all the stores.
for (SmallVector<Instruction*, 16>::const_iterator
for (SmallVectorImpl<Instruction *>::const_iterator
SI = Range.TheStores.begin(),
SE = Range.TheStores.end(); SI != SE; ++SI) {
MD->removeInstruction(*SI);
Expand Down
4 changes: 2 additions & 2 deletions lib/Transforms/Scalar/SROA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,15 @@ class AllocaPromoter : public LoadAndStorePromoter {
}

virtual void updateDebugInfo(Instruction *Inst) const {
for (SmallVector<DbgDeclareInst *, 4>::const_iterator I = DDIs.begin(),
for (SmallVectorImpl<DbgDeclareInst *>::const_iterator I = DDIs.begin(),
E = DDIs.end(); I != E; ++I) {
DbgDeclareInst *DDI = *I;
if (StoreInst *SI = dyn_cast<StoreInst>(Inst))
ConvertDebugDeclareToDebugValue(DDI, SI, DIB);
else if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
ConvertDebugDeclareToDebugValue(DDI, LI, DIB);
}
for (SmallVector<DbgValueInst *, 4>::const_iterator I = DVIs.begin(),
for (SmallVectorImpl<DbgValueInst *>::const_iterator I = DVIs.begin(),
E = DVIs.end(); I != E; ++I) {
DbgValueInst *DVI = *I;
Value *Arg = 0;
Expand Down
10 changes: 5 additions & 5 deletions lib/Transforms/Scalar/ScalarReplAggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,12 +1066,12 @@ class AllocaPromoter : public LoadAndStorePromoter {

LoadAndStorePromoter::run(Insts);
AI->eraseFromParent();
for (SmallVector<DbgDeclareInst *, 4>::iterator I = DDIs.begin(),
for (SmallVectorImpl<DbgDeclareInst *>::iterator I = DDIs.begin(),
E = DDIs.end(); I != E; ++I) {
DbgDeclareInst *DDI = *I;
DDI->eraseFromParent();
}
for (SmallVector<DbgValueInst *, 4>::iterator I = DVIs.begin(),
for (SmallVectorImpl<DbgValueInst *>::iterator I = DVIs.begin(),
E = DVIs.end(); I != E; ++I) {
DbgValueInst *DVI = *I;
DVI->eraseFromParent();
Expand All @@ -1086,15 +1086,15 @@ class AllocaPromoter : public LoadAndStorePromoter {
}

virtual void updateDebugInfo(Instruction *Inst) const {
for (SmallVector<DbgDeclareInst *, 4>::const_iterator I = DDIs.begin(),
for (SmallVectorImpl<DbgDeclareInst *>::const_iterator I = DDIs.begin(),
E = DDIs.end(); I != E; ++I) {
DbgDeclareInst *DDI = *I;
if (StoreInst *SI = dyn_cast<StoreInst>(Inst))
ConvertDebugDeclareToDebugValue(DDI, SI, *DIB);
else if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
ConvertDebugDeclareToDebugValue(DDI, LI, *DIB);
}
for (SmallVector<DbgValueInst *, 4>::const_iterator I = DVIs.begin(),
for (SmallVectorImpl<DbgValueInst *>::const_iterator I = DVIs.begin(),
E = DVIs.end(); I != E; ++I) {
DbgValueInst *DVI = *I;
Value *Arg = NULL;
Expand Down Expand Up @@ -2189,7 +2189,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *Inst,
if (OtherPtr == AI || OtherPtr == NewElts[0]) {
// This code will run twice for a no-op memcpy -- once for each operand.
// Put only one reference to MI on the DeadInsts list.
for (SmallVector<Value*, 32>::const_iterator I = DeadInsts.begin(),
for (SmallVectorImpl<Value *>::const_iterator I = DeadInsts.begin(),
E = DeadInsts.end(); I != E; ++I)
if (*I == MI) return;
DeadInsts.push_back(MI);
Expand Down

0 comments on commit 365ef0b

Please sign in to comment.