mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-12 07:37:34 +00:00
Use range based for loops to avoid needing to re-mention SmallPtrSet size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216351 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7bd541a4dc
commit
273fd11da9
include/llvm
lib
Analysis
CodeGen
LiveVariables.cppPHIElimination.cppPrologEpilogInserter.cppRegAllocFast.cpp
SelectionDAG
SjLjEHPrepare.cppUnreachableBlockElim.cppExecutionEngine/JIT
IR
Target
Transforms
tools/bugpoint
utils/TableGen
@ -231,6 +231,13 @@ df_ext_iterator<T, SetTy> df_ext_end(const T& G, SetTy &S) {
|
||||
return df_ext_iterator<T, SetTy>::end(G, S);
|
||||
}
|
||||
|
||||
template <class T, class SetTy>
|
||||
iterator_range<df_ext_iterator<T, SetTy>> depth_first_ext(const T& G,
|
||||
SetTy &S) {
|
||||
return iterator_range<df_ext_iterator<T, SetTy>>(df_ext_begin(G, S),
|
||||
df_ext_end(G, S));
|
||||
}
|
||||
|
||||
|
||||
// Provide global definitions of inverse depth first iterators...
|
||||
template <class T,
|
||||
@ -276,6 +283,13 @@ idf_ext_iterator<T, SetTy> idf_ext_end(const T& G, SetTy &S) {
|
||||
return idf_ext_iterator<T, SetTy>::end(Inverse<T>(G), S);
|
||||
}
|
||||
|
||||
template <class T, class SetTy>
|
||||
iterator_range<idf_ext_iterator<T, SetTy>> inverse_depth_first_ext(const T& G,
|
||||
SetTy &S) {
|
||||
return iterator_range<idf_ext_iterator<T, SetTy>>(idf_ext_begin(G, S),
|
||||
idf_ext_end(G, S));
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -107,11 +107,9 @@ public:
|
||||
PreservedPassIDs = Arg.PreservedPassIDs;
|
||||
return;
|
||||
}
|
||||
for (SmallPtrSet<void *, 2>::const_iterator I = PreservedPassIDs.begin(),
|
||||
E = PreservedPassIDs.end();
|
||||
I != E; ++I)
|
||||
if (!Arg.PreservedPassIDs.count(*I))
|
||||
PreservedPassIDs.erase(*I);
|
||||
for (void *P : PreservedPassIDs)
|
||||
if (!Arg.PreservedPassIDs.count(P))
|
||||
PreservedPassIDs.erase(P);
|
||||
}
|
||||
|
||||
/// \brief Intersect this set with a temporary other set in place.
|
||||
@ -125,11 +123,9 @@ public:
|
||||
PreservedPassIDs = std::move(Arg.PreservedPassIDs);
|
||||
return;
|
||||
}
|
||||
for (SmallPtrSet<void *, 2>::const_iterator I = PreservedPassIDs.begin(),
|
||||
E = PreservedPassIDs.end();
|
||||
I != E; ++I)
|
||||
if (!Arg.PreservedPassIDs.count(*I))
|
||||
PreservedPassIDs.erase(*I);
|
||||
for (void *P : PreservedPassIDs)
|
||||
if (!Arg.PreservedPassIDs.count(P))
|
||||
PreservedPassIDs.erase(P);
|
||||
}
|
||||
|
||||
/// \brief Query whether a pass is marked as preserved by this set.
|
||||
|
@ -1362,10 +1362,8 @@ bool BasicAliasAnalysis::isValueEqualInPotentialCycles(const Value *V,
|
||||
// Make sure that the visited phis cannot reach the Value. This ensures that
|
||||
// the Values cannot come from different iterations of a potential cycle the
|
||||
// phi nodes could be involved in.
|
||||
for (SmallPtrSet<const BasicBlock *, 8>::iterator PI = VisitedPhiBBs.begin(),
|
||||
PE = VisitedPhiBBs.end();
|
||||
PI != PE; ++PI)
|
||||
if (isPotentiallyReachable((*PI)->begin(), Inst, DT, LI))
|
||||
for (auto *P : VisitedPhiBBs)
|
||||
if (isPotentiallyReachable(P->begin(), Inst, DT, LI))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -1411,14 +1411,11 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
||||
|
||||
ReverseDepMapType::iterator ReverseDepIt = ReverseLocalDeps.find(RemInst);
|
||||
if (ReverseDepIt != ReverseLocalDeps.end()) {
|
||||
SmallPtrSet<Instruction*, 4> &ReverseDeps = ReverseDepIt->second;
|
||||
// RemInst can't be the terminator if it has local stuff depending on it.
|
||||
assert(!ReverseDeps.empty() && !isa<TerminatorInst>(RemInst) &&
|
||||
assert(!ReverseDepIt->second.empty() && !isa<TerminatorInst>(RemInst) &&
|
||||
"Nothing can locally depend on a terminator");
|
||||
|
||||
for (SmallPtrSet<Instruction*, 4>::iterator I = ReverseDeps.begin(),
|
||||
E = ReverseDeps.end(); I != E; ++I) {
|
||||
Instruction *InstDependingOnRemInst = *I;
|
||||
for (Instruction *InstDependingOnRemInst : ReverseDepIt->second) {
|
||||
assert(InstDependingOnRemInst != RemInst &&
|
||||
"Already removed our local dep info");
|
||||
|
||||
@ -1444,12 +1441,10 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
||||
|
||||
ReverseDepIt = ReverseNonLocalDeps.find(RemInst);
|
||||
if (ReverseDepIt != ReverseNonLocalDeps.end()) {
|
||||
SmallPtrSet<Instruction*, 4> &Set = ReverseDepIt->second;
|
||||
for (SmallPtrSet<Instruction*, 4>::iterator I = Set.begin(), E = Set.end();
|
||||
I != E; ++I) {
|
||||
assert(*I != RemInst && "Already removed NonLocalDep info for RemInst");
|
||||
for (Instruction *I : ReverseDepIt->second) {
|
||||
assert(I != RemInst && "Already removed NonLocalDep info for RemInst");
|
||||
|
||||
PerInstNLInfo &INLD = NonLocalDeps[*I];
|
||||
PerInstNLInfo &INLD = NonLocalDeps[I];
|
||||
// The information is now dirty!
|
||||
INLD.second = true;
|
||||
|
||||
@ -1461,7 +1456,7 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
||||
DI->setResult(NewDirtyVal);
|
||||
|
||||
if (Instruction *NextI = NewDirtyVal.getInst())
|
||||
ReverseDepsToAdd.push_back(std::make_pair(NextI, *I));
|
||||
ReverseDepsToAdd.push_back(std::make_pair(NextI, I));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1480,12 +1475,9 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
||||
ReverseNonLocalPtrDepTy::iterator ReversePtrDepIt =
|
||||
ReverseNonLocalPtrDeps.find(RemInst);
|
||||
if (ReversePtrDepIt != ReverseNonLocalPtrDeps.end()) {
|
||||
SmallPtrSet<ValueIsLoadPair, 4> &Set = ReversePtrDepIt->second;
|
||||
SmallVector<std::pair<Instruction*, ValueIsLoadPair>,8> ReversePtrDepsToAdd;
|
||||
|
||||
for (SmallPtrSet<ValueIsLoadPair, 4>::iterator I = Set.begin(),
|
||||
E = Set.end(); I != E; ++I) {
|
||||
ValueIsLoadPair P = *I;
|
||||
for (ValueIsLoadPair P : ReversePtrDepIt->second) {
|
||||
assert(P.getPointer() != RemInst &&
|
||||
"Already removed NonLocalPointerDeps info for RemInst");
|
||||
|
||||
@ -1526,8 +1518,10 @@ void MemoryDependenceAnalysis::removeInstruction(Instruction *RemInst) {
|
||||
DEBUG(verifyRemoved(RemInst));
|
||||
}
|
||||
/// verifyRemoved - Verify that the specified instruction does not occur
|
||||
/// in our internal data structures.
|
||||
/// in our internal data structures. This function verifies by asserting in
|
||||
/// debug builds.
|
||||
void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
|
||||
#ifndef NDEBUG
|
||||
for (LocalDepMapType::const_iterator I = LocalDeps.begin(),
|
||||
E = LocalDeps.end(); I != E; ++I) {
|
||||
assert(I->first != D && "Inst occurs in data structures");
|
||||
@ -1556,18 +1550,16 @@ void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
|
||||
for (ReverseDepMapType::const_iterator I = ReverseLocalDeps.begin(),
|
||||
E = ReverseLocalDeps.end(); I != E; ++I) {
|
||||
assert(I->first != D && "Inst occurs in data structures");
|
||||
for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
|
||||
EE = I->second.end(); II != EE; ++II)
|
||||
assert(*II != D && "Inst occurs in data structures");
|
||||
for (Instruction *Inst : I->second)
|
||||
assert(Inst != D && "Inst occurs in data structures");
|
||||
}
|
||||
|
||||
for (ReverseDepMapType::const_iterator I = ReverseNonLocalDeps.begin(),
|
||||
E = ReverseNonLocalDeps.end();
|
||||
I != E; ++I) {
|
||||
assert(I->first != D && "Inst occurs in data structures");
|
||||
for (SmallPtrSet<Instruction*, 4>::const_iterator II = I->second.begin(),
|
||||
EE = I->second.end(); II != EE; ++II)
|
||||
assert(*II != D && "Inst occurs in data structures");
|
||||
for (Instruction *Inst : I->second)
|
||||
assert(Inst != D && "Inst occurs in data structures");
|
||||
}
|
||||
|
||||
for (ReverseNonLocalPtrDepTy::const_iterator
|
||||
@ -1575,11 +1567,10 @@ void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
|
||||
E = ReverseNonLocalPtrDeps.end(); I != E; ++I) {
|
||||
assert(I->first != D && "Inst occurs in rev NLPD map");
|
||||
|
||||
for (SmallPtrSet<ValueIsLoadPair, 4>::const_iterator II = I->second.begin(),
|
||||
E = I->second.end(); II != E; ++II)
|
||||
assert(*II != ValueIsLoadPair(D, false) &&
|
||||
*II != ValueIsLoadPair(D, true) &&
|
||||
for (ValueIsLoadPair P : I->second)
|
||||
assert(P != ValueIsLoadPair(D, false) &&
|
||||
P != ValueIsLoadPair(D, true) &&
|
||||
"Inst occurs in ReverseNonLocalPtrDeps map");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -525,11 +525,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
|
||||
MachineBasicBlock *Entry = MF->begin();
|
||||
SmallPtrSet<MachineBasicBlock*,16> Visited;
|
||||
|
||||
for (df_ext_iterator<MachineBasicBlock*, SmallPtrSet<MachineBasicBlock*,16> >
|
||||
DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited);
|
||||
DFI != E; ++DFI) {
|
||||
MachineBasicBlock *MBB = *DFI;
|
||||
|
||||
for (MachineBasicBlock *MBB : depth_first_ext(Entry, Visited)) {
|
||||
// Mark live-in registers as live-in.
|
||||
SmallVector<unsigned, 4> Defs;
|
||||
for (MachineBasicBlock::livein_iterator II = MBB->livein_begin(),
|
||||
|
@ -151,9 +151,7 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
||||
Changed |= EliminatePHINodes(MF, *I);
|
||||
|
||||
// Remove dead IMPLICIT_DEF instructions.
|
||||
for (SmallPtrSet<MachineInstr*, 4>::iterator I = ImpDefs.begin(),
|
||||
E = ImpDefs.end(); I != E; ++I) {
|
||||
MachineInstr *DefMI = *I;
|
||||
for (MachineInstr *DefMI : ImpDefs) {
|
||||
unsigned DefReg = DefMI->getOperand(0).getReg();
|
||||
if (MRI->use_nodbg_empty(DefReg)) {
|
||||
if (LIS)
|
||||
|
@ -711,8 +711,7 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) {
|
||||
SmallPtrSet<MachineBasicBlock*, 8> Reachable;
|
||||
|
||||
// Iterate over the reachable blocks in DFS order.
|
||||
for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> >
|
||||
DFI = df_ext_begin(&Fn, Reachable), DFE = df_ext_end(&Fn, Reachable);
|
||||
for (auto DFI = df_ext_begin(&Fn, Reachable), DFE = df_ext_end(&Fn, Reachable);
|
||||
DFI != DFE; ++DFI) {
|
||||
int SPAdj = 0;
|
||||
// Check the exit state of the DFS stack predecessor.
|
||||
|
@ -1094,9 +1094,8 @@ bool RAFast::runOnMachineFunction(MachineFunction &Fn) {
|
||||
}
|
||||
|
||||
// Add the clobber lists for all the instructions we skipped earlier.
|
||||
for (SmallPtrSet<const MCInstrDesc*, 4>::const_iterator
|
||||
I = SkippedInstrs.begin(), E = SkippedInstrs.end(); I != E; ++I)
|
||||
if (const uint16_t *Defs = (*I)->getImplicitDefs())
|
||||
for (const MCInstrDesc *Desc : SkippedInstrs)
|
||||
if (const uint16_t *Defs = Desc->getImplicitDefs())
|
||||
while (*Defs)
|
||||
MRI->setPhysRegUsed(*Defs++);
|
||||
|
||||
|
@ -11930,10 +11930,9 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDValue OriginalChain,
|
||||
// like register copies will interfere with trivial cases).
|
||||
|
||||
SmallVector<const SDNode *, 16> Worklist;
|
||||
for (SmallPtrSet<SDNode *, 16>::iterator I = Visited.begin(),
|
||||
IE = Visited.end(); I != IE; ++I)
|
||||
if (*I != OriginalChain.getNode())
|
||||
Worklist.push_back(*I);
|
||||
for (const SDNode *N : Visited)
|
||||
if (N != OriginalChain.getNode())
|
||||
Worklist.push_back(N);
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
const SDNode *M = Worklist.pop_back_val();
|
||||
|
@ -5554,10 +5554,9 @@ SDNode *SelectionDAG::MorphNodeTo(SDNode *N, unsigned Opc,
|
||||
// new operands.
|
||||
if (!DeadNodeSet.empty()) {
|
||||
SmallVector<SDNode *, 16> DeadNodes;
|
||||
for (SmallPtrSet<SDNode *, 16>::iterator I = DeadNodeSet.begin(),
|
||||
E = DeadNodeSet.end(); I != E; ++I)
|
||||
if ((*I)->use_empty())
|
||||
DeadNodes.push_back(*I);
|
||||
for (SDNode *N : DeadNodeSet)
|
||||
if (N->use_empty())
|
||||
DeadNodes.push_back(N);
|
||||
RemoveDeadNodes(DeadNodes);
|
||||
}
|
||||
|
||||
|
@ -351,10 +351,8 @@ void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F,
|
||||
continue;
|
||||
|
||||
// Demote the PHIs to the stack.
|
||||
for (SmallPtrSet<PHINode *, 8>::iterator I = PHIsToDemote.begin(),
|
||||
E = PHIsToDemote.end();
|
||||
I != E; ++I)
|
||||
DemotePHIToStack(*I);
|
||||
for (PHINode *PN : PHIsToDemote)
|
||||
DemotePHIToStack(PN);
|
||||
|
||||
// Move the landingpad instruction back to the top of the landing pad block.
|
||||
LPI->moveBefore(UnwindBlock->begin());
|
||||
|
@ -64,9 +64,8 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
|
||||
SmallPtrSet<BasicBlock*, 8> Reachable;
|
||||
|
||||
// Mark all reachable blocks.
|
||||
for (df_ext_iterator<Function*, SmallPtrSet<BasicBlock*, 8> > I =
|
||||
df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable); I != E; ++I)
|
||||
/* Mark all reachable blocks */;
|
||||
for (BasicBlock *BB : depth_first_ext(&F, Reachable))
|
||||
(void)BB/* Mark all reachable blocks */;
|
||||
|
||||
// Loop over all dead blocks, remembering them and deleting all instructions
|
||||
// in them.
|
||||
@ -125,10 +124,8 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
||||
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
||||
|
||||
// Mark all reachable blocks.
|
||||
for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> >
|
||||
I = df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable);
|
||||
I != E; ++I)
|
||||
/* Mark all reachable blocks */;
|
||||
for (MachineBasicBlock *BB : depth_first_ext(&F, Reachable))
|
||||
(void)BB/* Mark all reachable blocks */;
|
||||
|
||||
// Loop over all dead blocks, remembering them and deleting all instructions
|
||||
// in them.
|
||||
|
@ -110,11 +110,9 @@ public:
|
||||
MutexGuard guard(Lock);
|
||||
assert(JITs.size() != 0 && "No Jit registered");
|
||||
//search function in every instance of JIT
|
||||
for (SmallPtrSet<JIT*, 1>::const_iterator Jit = JITs.begin(),
|
||||
end = JITs.end();
|
||||
Jit != end; ++Jit) {
|
||||
if (Function *F = (*Jit)->FindFunctionNamed(Name))
|
||||
return (*Jit)->getPointerToFunction(F);
|
||||
for (JIT *Jit : JITs) {
|
||||
if (Function *F = Jit->FindFunctionNamed(Name))
|
||||
return Jit->getPointerToFunction(F);
|
||||
}
|
||||
// The function is not available : fallback on the first created (will
|
||||
// search in symbol of the current program/library)
|
||||
|
@ -462,10 +462,9 @@ void JITResolverState::EraseAllCallSitesForPrelocked(Function *F) {
|
||||
if (F2C == FunctionToCallSitesMap.end())
|
||||
return;
|
||||
StubToResolverMapTy &S2RMap = *StubToResolverMap;
|
||||
for (SmallPtrSet<void*, 1>::const_iterator I = F2C->second.begin(),
|
||||
E = F2C->second.end(); I != E; ++I) {
|
||||
S2RMap.UnregisterStubResolver(*I);
|
||||
bool Erased = CallSiteToFunctionMap.erase(*I);
|
||||
for (void *C : F2C->second) {
|
||||
S2RMap.UnregisterStubResolver(C);
|
||||
bool Erased = CallSiteToFunctionMap.erase(C);
|
||||
(void)Erased;
|
||||
assert(Erased && "Missing call site->function mapping");
|
||||
}
|
||||
|
@ -573,9 +573,8 @@ void PMTopLevelManager::collectLastUses(SmallVectorImpl<Pass *> &LastUses,
|
||||
return;
|
||||
|
||||
SmallPtrSet<Pass *, 8> &LU = DMI->second;
|
||||
for (SmallPtrSet<Pass *, 8>::iterator I = LU.begin(),
|
||||
E = LU.end(); I != E; ++I) {
|
||||
LastUses.push_back(*I);
|
||||
for (Pass *LUP : LU) {
|
||||
LastUses.push_back(LUP);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6924,9 +6924,7 @@ EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const {
|
||||
// N.B. the order the invoke BBs are processed in doesn't matter here.
|
||||
const MCPhysReg *SavedRegs = RI.getCalleeSavedRegs(MF);
|
||||
SmallVector<MachineBasicBlock*, 64> MBBLPads;
|
||||
for (SmallPtrSet<MachineBasicBlock*, 64>::iterator
|
||||
I = InvokeBBs.begin(), E = InvokeBBs.end(); I != E; ++I) {
|
||||
MachineBasicBlock *BB = *I;
|
||||
for (MachineBasicBlock *BB : InvokeBBs) {
|
||||
|
||||
// Remove the landing pad successor from the invoke block and replace it
|
||||
// with the new dispatch block.
|
||||
|
@ -324,10 +324,8 @@ bool FPS::runOnMachineFunction(MachineFunction &MF) {
|
||||
MachineBasicBlock *Entry = MF.begin();
|
||||
|
||||
bool Changed = false;
|
||||
for (df_ext_iterator<MachineBasicBlock*, SmallPtrSet<MachineBasicBlock*, 8> >
|
||||
I = df_ext_begin(Entry, Processed), E = df_ext_end(Entry, Processed);
|
||||
I != E; ++I)
|
||||
Changed |= processBasicBlock(MF, **I);
|
||||
for (MachineBasicBlock *BB : depth_first_ext(Entry, Processed))
|
||||
Changed |= processBasicBlock(MF, *BB);
|
||||
|
||||
// Process any unreachable blocks in arbitrary order now.
|
||||
if (MF.size() != Processed.size())
|
||||
|
@ -477,10 +477,8 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg,
|
||||
// loading block.
|
||||
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
|
||||
BasicBlock *P = *PI;
|
||||
for (idf_ext_iterator<BasicBlock*, SmallPtrSet<BasicBlock*, 16> >
|
||||
I = idf_ext_begin(P, TranspBlocks),
|
||||
E = idf_ext_end(P, TranspBlocks); I != E; ++I)
|
||||
if (AA.canBasicBlockModify(**I, Loc))
|
||||
for (BasicBlock *TranspBB : inverse_depth_first_ext(P, TranspBlocks))
|
||||
if (AA.canBasicBlockModify(*TranspBB, Loc))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1115,9 +1115,7 @@ static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA(const GlobalVariable *GV,
|
||||
// that all inputs the to the PHI nodes are in the same equivalence sets.
|
||||
// Check to verify that all operands of the PHIs are either PHIS that can be
|
||||
// transformed, loads from GV, or MI itself.
|
||||
for (SmallPtrSet<const PHINode*, 32>::const_iterator I = LoadUsingPHIs.begin()
|
||||
, E = LoadUsingPHIs.end(); I != E; ++I) {
|
||||
const PHINode *PN = *I;
|
||||
for (const PHINode *PN : LoadUsingPHIs) {
|
||||
for (unsigned op = 0, e = PN->getNumIncomingValues(); op != e; ++op) {
|
||||
Value *InVal = PN->getIncomingValue(op);
|
||||
|
||||
@ -2711,10 +2709,8 @@ static bool EvaluateStaticConstructor(Function *F, const DataLayout *DL,
|
||||
Eval.getMutatedMemory().begin(), E = Eval.getMutatedMemory().end();
|
||||
I != E; ++I)
|
||||
CommitValueTo(I->second, I->first);
|
||||
for (SmallPtrSet<GlobalVariable*, 8>::const_iterator I =
|
||||
Eval.getInvariants().begin(), E = Eval.getInvariants().end();
|
||||
I != E; ++I)
|
||||
(*I)->setConstant(true);
|
||||
for (GlobalVariable *GV : Eval.getInvariants())
|
||||
GV->setConstant(true);
|
||||
}
|
||||
|
||||
return EvalSuccess;
|
||||
@ -2768,10 +2764,17 @@ public:
|
||||
CompilerUsedV = collectUsedGlobalVariables(M, CompilerUsed, true);
|
||||
}
|
||||
typedef SmallPtrSet<GlobalValue *, 8>::iterator iterator;
|
||||
typedef iterator_range<iterator> used_iterator_range;
|
||||
iterator usedBegin() { return Used.begin(); }
|
||||
iterator usedEnd() { return Used.end(); }
|
||||
used_iterator_range used() {
|
||||
return used_iterator_range(usedBegin(), usedEnd());
|
||||
}
|
||||
iterator compilerUsedBegin() { return CompilerUsed.begin(); }
|
||||
iterator compilerUsedEnd() { return CompilerUsed.end(); }
|
||||
used_iterator_range compilerUsed() {
|
||||
return used_iterator_range(compilerUsedBegin(), compilerUsedEnd());
|
||||
}
|
||||
bool usedCount(GlobalValue *GV) const { return Used.count(GV); }
|
||||
bool compilerUsedCount(GlobalValue *GV) const {
|
||||
return CompilerUsed.count(GV);
|
||||
@ -2860,8 +2863,8 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
|
||||
bool Changed = false;
|
||||
LLVMUsed Used(M);
|
||||
|
||||
for (LLVMUsed::iterator I = Used.usedBegin(), E = Used.usedEnd(); I != E; ++I)
|
||||
Used.compilerUsedErase(*I);
|
||||
for (GlobalValue *GV : Used.used())
|
||||
Used.compilerUsedErase(GV);
|
||||
|
||||
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
|
||||
I != E;) {
|
||||
|
@ -148,9 +148,7 @@ bool InternalizePass::runOnModule(Module &M) {
|
||||
// we don't see references from function local inline assembly. To be
|
||||
// conservative, we internalize symbols in llvm.compiler.used, but we
|
||||
// keep llvm.compiler.used so that the symbol is not deleted by llvm.
|
||||
for (SmallPtrSet<GlobalValue *, 8>::iterator I = Used.begin(), E = Used.end();
|
||||
I != E; ++I) {
|
||||
GlobalValue *V = *I;
|
||||
for (GlobalValue *V : Used) {
|
||||
ExternalNames.insert(V->getName());
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,8 @@ static void RemoveDeadConstant(Constant *C) {
|
||||
C->destroyConstant();
|
||||
|
||||
// If the constant referenced anything, see if we can delete it as well.
|
||||
for (SmallPtrSet<Constant*, 4>::iterator OI = Operands.begin(),
|
||||
OE = Operands.end(); OI != OE; ++OI)
|
||||
RemoveDeadConstant(*OI);
|
||||
for (Constant *O : Operands)
|
||||
RemoveDeadConstant(O);
|
||||
}
|
||||
|
||||
// Strip the symbol table of its names.
|
||||
|
@ -246,9 +246,7 @@ llvm::objcarc::FindDependencies(DependenceKind Flavor,
|
||||
// Determine whether the original StartBB post-dominates all of the blocks we
|
||||
// visited. If not, insert a sentinal indicating that most optimizations are
|
||||
// not safe.
|
||||
for (SmallPtrSet<const BasicBlock *, 4>::const_iterator I = Visited.begin(),
|
||||
E = Visited.end(); I != E; ++I) {
|
||||
const BasicBlock *BB = *I;
|
||||
for (const BasicBlock *BB : Visited) {
|
||||
if (BB == StartBB)
|
||||
continue;
|
||||
const TerminatorInst *TI = cast<TerminatorInst>(&BB->back());
|
||||
|
@ -508,9 +508,8 @@ bool ObjCARCContract::runOnFunction(Function &F) {
|
||||
// If this function has no escaping allocas or suspicious vararg usage,
|
||||
// objc_storeStrong calls can be marked with the "tail" keyword.
|
||||
if (TailOkForStoreStrongs)
|
||||
for (SmallPtrSet<CallInst *, 8>::iterator I = StoreStrongCalls.begin(),
|
||||
E = StoreStrongCalls.end(); I != E; ++I)
|
||||
(*I)->setTailCall();
|
||||
for (CallInst *CI : StoreStrongCalls)
|
||||
CI->setTailCall();
|
||||
StoreStrongCalls.clear();
|
||||
|
||||
return Changed;
|
||||
|
@ -411,10 +411,8 @@ bool RRInfo::Merge(const RRInfo &Other) {
|
||||
// Merge the insert point sets. If there are any differences,
|
||||
// that makes this a partial merge.
|
||||
bool Partial = ReverseInsertPts.size() != Other.ReverseInsertPts.size();
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
I = Other.ReverseInsertPts.begin(),
|
||||
E = Other.ReverseInsertPts.end(); I != E; ++I)
|
||||
Partial |= ReverseInsertPts.insert(*I);
|
||||
for (Instruction *Inst : Other.ReverseInsertPts)
|
||||
Partial |= ReverseInsertPts.insert(Inst);
|
||||
return Partial;
|
||||
}
|
||||
|
||||
@ -2299,10 +2297,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg,
|
||||
DEBUG(dbgs() << "== ObjCARCOpt::MoveCalls ==\n");
|
||||
|
||||
// Insert the new retain and release calls.
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
PI = ReleasesToMove.ReverseInsertPts.begin(),
|
||||
PE = ReleasesToMove.ReverseInsertPts.end(); PI != PE; ++PI) {
|
||||
Instruction *InsertPt = *PI;
|
||||
for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) {
|
||||
Value *MyArg = ArgTy == ParamTy ? Arg :
|
||||
new BitCastInst(Arg, ParamTy, "", InsertPt);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
|
||||
@ -2313,10 +2308,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg,
|
||||
DEBUG(dbgs() << "Inserting new Retain: " << *Call << "\n"
|
||||
"At insertion point: " << *InsertPt << "\n");
|
||||
}
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
PI = RetainsToMove.ReverseInsertPts.begin(),
|
||||
PE = RetainsToMove.ReverseInsertPts.end(); PI != PE; ++PI) {
|
||||
Instruction *InsertPt = *PI;
|
||||
for (Instruction *InsertPt : RetainsToMove.ReverseInsertPts) {
|
||||
Value *MyArg = ArgTy == ParamTy ? Arg :
|
||||
new BitCastInst(Arg, ParamTy, "", InsertPt);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Release);
|
||||
@ -2333,18 +2325,12 @@ void ObjCARCOpt::MoveCalls(Value *Arg,
|
||||
}
|
||||
|
||||
// Delete the original retain and release calls.
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
AI = RetainsToMove.Calls.begin(),
|
||||
AE = RetainsToMove.Calls.end(); AI != AE; ++AI) {
|
||||
Instruction *OrigRetain = *AI;
|
||||
for (Instruction *OrigRetain : RetainsToMove.Calls) {
|
||||
Retains.blot(OrigRetain);
|
||||
DeadInsts.push_back(OrigRetain);
|
||||
DEBUG(dbgs() << "Deleting retain: " << *OrigRetain << "\n");
|
||||
}
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
AI = ReleasesToMove.Calls.begin(),
|
||||
AE = ReleasesToMove.Calls.end(); AI != AE; ++AI) {
|
||||
Instruction *OrigRelease = *AI;
|
||||
for (Instruction *OrigRelease : ReleasesToMove.Calls) {
|
||||
Releases.erase(OrigRelease);
|
||||
DeadInsts.push_back(OrigRelease);
|
||||
DEBUG(dbgs() << "Deleting release: " << *OrigRelease << "\n");
|
||||
@ -2392,10 +2378,7 @@ ObjCARCOpt::ConnectTDBUTraversals(DenseMap<const BasicBlock *, BBState>
|
||||
KnownSafeTD &= NewRetainRRI.KnownSafe;
|
||||
MultipleOwners =
|
||||
MultipleOwners || MultiOwnersSet.count(GetObjCArg(NewRetain));
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
LI = NewRetainRRI.Calls.begin(),
|
||||
LE = NewRetainRRI.Calls.end(); LI != LE; ++LI) {
|
||||
Instruction *NewRetainRelease = *LI;
|
||||
for (Instruction *NewRetainRelease : NewRetainRRI.Calls) {
|
||||
DenseMap<Value *, RRInfo>::const_iterator Jt =
|
||||
Releases.find(NewRetainRelease);
|
||||
if (Jt == Releases.end())
|
||||
@ -2441,11 +2424,7 @@ ObjCARCOpt::ConnectTDBUTraversals(DenseMap<const BasicBlock *, BBState>
|
||||
|
||||
// Collect the optimal insertion points.
|
||||
if (!KnownSafe)
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
RI = NewRetainReleaseRRI.ReverseInsertPts.begin(),
|
||||
RE = NewRetainReleaseRRI.ReverseInsertPts.end();
|
||||
RI != RE; ++RI) {
|
||||
Instruction *RIP = *RI;
|
||||
for (Instruction *RIP : NewRetainReleaseRRI.ReverseInsertPts) {
|
||||
if (ReleasesToMove.ReverseInsertPts.insert(RIP)) {
|
||||
// If we overflow when we compute the path count, don't
|
||||
// remove/move anything.
|
||||
@ -2476,10 +2455,7 @@ ObjCARCOpt::ConnectTDBUTraversals(DenseMap<const BasicBlock *, BBState>
|
||||
const RRInfo &NewReleaseRRI = It->second;
|
||||
KnownSafeBU &= NewReleaseRRI.KnownSafe;
|
||||
CFGHazardAfflicted |= NewReleaseRRI.CFGHazardAfflicted;
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
LI = NewReleaseRRI.Calls.begin(),
|
||||
LE = NewReleaseRRI.Calls.end(); LI != LE; ++LI) {
|
||||
Instruction *NewReleaseRetain = *LI;
|
||||
for (Instruction *NewReleaseRetain : NewReleaseRRI.Calls) {
|
||||
MapVector<Value *, RRInfo>::const_iterator Jt =
|
||||
Retains.find(NewReleaseRetain);
|
||||
if (Jt == Retains.end())
|
||||
@ -2509,11 +2485,7 @@ ObjCARCOpt::ConnectTDBUTraversals(DenseMap<const BasicBlock *, BBState>
|
||||
|
||||
// Collect the optimal insertion points.
|
||||
if (!KnownSafe)
|
||||
for (SmallPtrSet<Instruction *, 2>::const_iterator
|
||||
RI = NewReleaseRetainRRI.ReverseInsertPts.begin(),
|
||||
RE = NewReleaseRetainRRI.ReverseInsertPts.end();
|
||||
RI != RE; ++RI) {
|
||||
Instruction *RIP = *RI;
|
||||
for (Instruction *RIP : NewReleaseRetainRRI.ReverseInsertPts) {
|
||||
if (RetainsToMove.ReverseInsertPts.insert(RIP)) {
|
||||
// If we overflow when we compute the path count, don't
|
||||
// remove/move anything.
|
||||
|
@ -239,9 +239,8 @@ bool LoopDeletion::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
LoopInfo &loopInfo = getAnalysis<LoopInfo>();
|
||||
SmallPtrSet<BasicBlock*, 8> blocks;
|
||||
blocks.insert(L->block_begin(), L->block_end());
|
||||
for (SmallPtrSet<BasicBlock*,8>::iterator I = blocks.begin(),
|
||||
E = blocks.end(); I != E; ++I)
|
||||
loopInfo.removeBlock(*I);
|
||||
for (BasicBlock *BB : blocks)
|
||||
loopInfo.removeBlock(BB);
|
||||
|
||||
// The last step is to inform the loop pass manager that we've
|
||||
// eliminated this loop.
|
||||
|
@ -1337,10 +1337,9 @@ void LSRUse::RecomputeRegs(size_t LUIdx, RegUseTracker &RegUses) {
|
||||
}
|
||||
|
||||
// Update the RegTracker.
|
||||
for (SmallPtrSet<const SCEV *, 4>::iterator I = OldRegs.begin(),
|
||||
E = OldRegs.end(); I != E; ++I)
|
||||
if (!Regs.count(*I))
|
||||
RegUses.DropRegister(*I, LUIdx);
|
||||
for (const SCEV *S : OldRegs)
|
||||
if (!Regs.count(S))
|
||||
RegUses.DropRegister(S, LUIdx);
|
||||
}
|
||||
|
||||
void LSRUse::print(raw_ostream &OS) const {
|
||||
@ -2226,13 +2225,12 @@ LSRInstance::OptimizeLoopTermCond() {
|
||||
// must dominate all the post-inc comparisons we just set up, and it must
|
||||
// dominate the loop latch edge.
|
||||
IVIncInsertPos = L->getLoopLatch()->getTerminator();
|
||||
for (SmallPtrSet<Instruction *, 4>::const_iterator I = PostIncs.begin(),
|
||||
E = PostIncs.end(); I != E; ++I) {
|
||||
for (Instruction *Inst : PostIncs) {
|
||||
BasicBlock *BB =
|
||||
DT.findNearestCommonDominator(IVIncInsertPos->getParent(),
|
||||
(*I)->getParent());
|
||||
if (BB == (*I)->getParent())
|
||||
IVIncInsertPos = *I;
|
||||
Inst->getParent());
|
||||
if (BB == Inst->getParent())
|
||||
IVIncInsertPos = Inst;
|
||||
else if (BB != IVIncInsertPos->getParent())
|
||||
IVIncInsertPos = BB->getTerminator();
|
||||
}
|
||||
@ -2567,9 +2565,8 @@ isProfitableChain(IVChain &Chain, SmallPtrSetImpl<Instruction*> &Users,
|
||||
|
||||
if (!Users.empty()) {
|
||||
DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " users:\n";
|
||||
for (SmallPtrSet<Instruction*, 4>::const_iterator I = Users.begin(),
|
||||
E = Users.end(); I != E; ++I) {
|
||||
dbgs() << " " << **I << "\n";
|
||||
for (Instruction *Inst : Users) {
|
||||
dbgs() << " " << *Inst << "\n";
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@ -4302,10 +4299,9 @@ void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution,
|
||||
// reference that register in order to be considered. This prunes out
|
||||
// unprofitable searching.
|
||||
SmallSetVector<const SCEV *, 4> ReqRegs;
|
||||
for (SmallPtrSet<const SCEV *, 16>::const_iterator I = CurRegs.begin(),
|
||||
E = CurRegs.end(); I != E; ++I)
|
||||
if (LU.Regs.count(*I))
|
||||
ReqRegs.insert(*I);
|
||||
for (const SCEV *S : CurRegs)
|
||||
if (LU.Regs.count(S))
|
||||
ReqRegs.insert(S);
|
||||
|
||||
SmallPtrSet<const SCEV *, 16> NewRegs;
|
||||
Cost NewCost;
|
||||
@ -4350,9 +4346,8 @@ void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution,
|
||||
} else {
|
||||
DEBUG(dbgs() << "New best at "; NewCost.print(dbgs());
|
||||
dbgs() << ".\n Regs:";
|
||||
for (SmallPtrSet<const SCEV *, 16>::const_iterator
|
||||
I = NewRegs.begin(), E = NewRegs.end(); I != E; ++I)
|
||||
dbgs() << ' ' << **I;
|
||||
for (const SCEV *S : NewRegs)
|
||||
dbgs() << ' ' << *S;
|
||||
dbgs() << '\n');
|
||||
|
||||
SolutionCost = NewCost;
|
||||
|
@ -166,9 +166,8 @@ static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA,
|
||||
|
||||
if (LoadInst *L = dyn_cast<LoadInst>(Inst)) {
|
||||
AliasAnalysis::Location Loc = AA->getLocation(L);
|
||||
for (SmallPtrSet<Instruction *, 8>::iterator I = Stores.begin(),
|
||||
E = Stores.end(); I != E; ++I)
|
||||
if (AA->getModRefInfo(*I, Loc) & AliasAnalysis::Mod)
|
||||
for (Instruction *S : Stores)
|
||||
if (AA->getModRefInfo(S, Loc) & AliasAnalysis::Mod)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -247,9 +247,7 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
|
||||
// Append the clauses from the outer landing pad instruction into the inlined
|
||||
// landing pad instructions.
|
||||
LandingPadInst *OuterLPad = Invoke.getLandingPadInst();
|
||||
for (SmallPtrSet<LandingPadInst*, 16>::iterator I = InlinedLPads.begin(),
|
||||
E = InlinedLPads.end(); I != E; ++I) {
|
||||
LandingPadInst *InlinedLPad = *I;
|
||||
for (LandingPadInst *InlinedLPad : InlinedLPads) {
|
||||
unsigned OuterNum = OuterLPad->getNumClauses();
|
||||
InlinedLPad->reserveClauses(OuterNum);
|
||||
for (unsigned OuterIdx = 0; OuterIdx != OuterNum; ++OuterIdx)
|
||||
|
@ -496,20 +496,19 @@ ReprocessLoop:
|
||||
}
|
||||
|
||||
// Delete each unique out-of-loop (and thus dead) predecessor.
|
||||
for (SmallPtrSet<BasicBlock*, 4>::iterator I = BadPreds.begin(),
|
||||
E = BadPreds.end(); I != E; ++I) {
|
||||
for (BasicBlock *P : BadPreds) {
|
||||
|
||||
DEBUG(dbgs() << "LoopSimplify: Deleting edge from dead predecessor "
|
||||
<< (*I)->getName() << "\n");
|
||||
<< P->getName() << "\n");
|
||||
|
||||
// Inform each successor of each dead pred.
|
||||
for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I); SI != SE; ++SI)
|
||||
(*SI)->removePredecessor(*I);
|
||||
for (succ_iterator SI = succ_begin(P), SE = succ_end(P); SI != SE; ++SI)
|
||||
(*SI)->removePredecessor(P);
|
||||
// Zap the dead pred's terminator and replace it with unreachable.
|
||||
TerminatorInst *TI = (*I)->getTerminator();
|
||||
TerminatorInst *TI = P->getTerminator();
|
||||
TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
|
||||
(*I)->getTerminator()->eraseFromParent();
|
||||
new UnreachableInst((*I)->getContext(), *I);
|
||||
P->getTerminator()->eraseFromParent();
|
||||
new UnreachableInst(P->getContext(), P);
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -857,10 +857,8 @@ void PromoteMem2Reg::DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
|
||||
less_second> IDFPriorityQueue;
|
||||
IDFPriorityQueue PQ;
|
||||
|
||||
for (SmallPtrSet<BasicBlock *, 32>::const_iterator I = DefBlocks.begin(),
|
||||
E = DefBlocks.end();
|
||||
I != E; ++I) {
|
||||
if (DomTreeNode *Node = DT.getNode(*I))
|
||||
for (BasicBlock *BB : DefBlocks) {
|
||||
if (DomTreeNode *Node = DT.getNode(BB))
|
||||
PQ.push(std::make_pair(Node, DomLevels[Node]));
|
||||
}
|
||||
|
||||
|
@ -312,10 +312,9 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
||||
// have to take.
|
||||
std::vector<std::pair<std::string, std::string> > BlockInfo;
|
||||
|
||||
for (SmallPtrSet<BasicBlock*, 8>::iterator I = Blocks.begin(),
|
||||
E = Blocks.end(); I != E; ++I)
|
||||
BlockInfo.push_back(std::make_pair((*I)->getParent()->getName(),
|
||||
(*I)->getName()));
|
||||
for (BasicBlock *BB : Blocks)
|
||||
BlockInfo.push_back(std::make_pair(BB->getParent()->getName(),
|
||||
BB->getName()));
|
||||
|
||||
// Now run the CFG simplify pass on the function...
|
||||
std::vector<std::string> Passes;
|
||||
@ -420,9 +419,8 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
|
||||
// Make sure to use instruction pointers that point into the now-current
|
||||
// module, and that they don't include any deleted blocks.
|
||||
Insts.clear();
|
||||
for (SmallPtrSet<Instruction*, 64>::const_iterator I = Instructions.begin(),
|
||||
E = Instructions.end(); I != E; ++I)
|
||||
Insts.push_back(*I);
|
||||
for (Instruction *Inst : Instructions)
|
||||
Insts.push_back(Inst);
|
||||
return true;
|
||||
}
|
||||
delete M; // It didn't crash, try something else.
|
||||
|
@ -901,9 +901,8 @@ CodeGenRegisterClass::getSuperRegClasses(CodeGenSubRegIndex *SubIdx,
|
||||
FindI = SuperRegClasses.find(SubIdx);
|
||||
if (FindI == SuperRegClasses.end())
|
||||
return;
|
||||
for (SmallPtrSet<CodeGenRegisterClass*, 8>::const_iterator I =
|
||||
FindI->second.begin(), E = FindI->second.end(); I != E; ++I)
|
||||
Out.set((*I)->EnumValue);
|
||||
for (CodeGenRegisterClass *RC : FindI->second)
|
||||
Out.set(RC->EnumValue);
|
||||
}
|
||||
|
||||
// Populate a unique sorted list of units from a register set.
|
||||
|
Loading…
x
Reference in New Issue
Block a user