llvm.org GIT mirror llvm / 273fd11
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 Craig Topper 5 years ago
32 changed file(s) with 135 addition(s) and 207 deletion(s). Raw diff Collapse all Expand all
230230 return df_ext_iterator::end(G, S);
231231 }
232232
233 template
234 iterator_range> depth_first_ext(const T& G,
235 SetTy &S) {
236 return iterator_range>(df_ext_begin(G, S),
237 df_ext_end(G, S));
238 }
239
233240
234241 // Provide global definitions of inverse depth first iterators...
235242 template
275282 return idf_ext_iterator::end(Inverse(G), S);
276283 }
277284
285 template
286 iterator_range> inverse_depth_first_ext(const T& G,
287 SetTy &S) {
288 return iterator_range>(idf_ext_begin(G, S),
289 idf_ext_end(G, S));
290 }
291
278292 } // End llvm namespace
279293
280294 #endif
106106 PreservedPassIDs = Arg.PreservedPassIDs;
107107 return;
108108 }
109 for (SmallPtrSet::const_iterator I = PreservedPassIDs.begin(),
110 E = PreservedPassIDs.end();
111 I != E; ++I)
112 if (!Arg.PreservedPassIDs.count(*I))
113 PreservedPassIDs.erase(*I);
109 for (void *P : PreservedPassIDs)
110 if (!Arg.PreservedPassIDs.count(P))
111 PreservedPassIDs.erase(P);
114112 }
115113
116114 /// \brief Intersect this set with a temporary other set in place.
124122 PreservedPassIDs = std::move(Arg.PreservedPassIDs);
125123 return;
126124 }
127 for (SmallPtrSet::const_iterator I = PreservedPassIDs.begin(),
128 E = PreservedPassIDs.end();
129 I != E; ++I)
130 if (!Arg.PreservedPassIDs.count(*I))
131 PreservedPassIDs.erase(*I);
125 for (void *P : PreservedPassIDs)
126 if (!Arg.PreservedPassIDs.count(P))
127 PreservedPassIDs.erase(P);
132128 }
133129
134130 /// \brief Query whether a pass is marked as preserved by this set.
13611361 // Make sure that the visited phis cannot reach the Value. This ensures that
13621362 // the Values cannot come from different iterations of a potential cycle the
13631363 // phi nodes could be involved in.
1364 for (SmallPtrSet::iterator PI = VisitedPhiBBs.begin(),
1365 PE = VisitedPhiBBs.end();
1366 PI != PE; ++PI)
1367 if (isPotentiallyReachable((*PI)->begin(), Inst, DT, LI))
1364 for (auto *P : VisitedPhiBBs)
1365 if (isPotentiallyReachable(P->begin(), Inst, DT, LI))
13681366 return false;
13691367
13701368 return true;
14101410
14111411 ReverseDepMapType::iterator ReverseDepIt = ReverseLocalDeps.find(RemInst);
14121412 if (ReverseDepIt != ReverseLocalDeps.end()) {
1413 SmallPtrSet &ReverseDeps = ReverseDepIt->second;
14141413 // RemInst can't be the terminator if it has local stuff depending on it.
1415 assert(!ReverseDeps.empty() && !isa(RemInst) &&
1414 assert(!ReverseDepIt->second.empty() && !isa(RemInst) &&
14161415 "Nothing can locally depend on a terminator");
14171416
1418 for (SmallPtrSet::iterator I = ReverseDeps.begin(),
1419 E = ReverseDeps.end(); I != E; ++I) {
1420 Instruction *InstDependingOnRemInst = *I;
1417 for (Instruction *InstDependingOnRemInst : ReverseDepIt->second) {
14211418 assert(InstDependingOnRemInst != RemInst &&
14221419 "Already removed our local dep info");
14231420
14431440
14441441 ReverseDepIt = ReverseNonLocalDeps.find(RemInst);
14451442 if (ReverseDepIt != ReverseNonLocalDeps.end()) {
1446 SmallPtrSet &Set = ReverseDepIt->second;
1447 for (SmallPtrSet::iterator I = Set.begin(), E = Set.end();
1448 I != E; ++I) {
1449 assert(*I != RemInst && "Already removed NonLocalDep info for RemInst");
1450
1451 PerInstNLInfo &INLD = NonLocalDeps[*I];
1443 for (Instruction *I : ReverseDepIt->second) {
1444 assert(I != RemInst && "Already removed NonLocalDep info for RemInst");
1445
1446 PerInstNLInfo &INLD = NonLocalDeps[I];
14521447 // The information is now dirty!
14531448 INLD.second = true;
14541449
14601455 DI->setResult(NewDirtyVal);
14611456
14621457 if (Instruction *NextI = NewDirtyVal.getInst())
1463 ReverseDepsToAdd.push_back(std::make_pair(NextI, *I));
1458 ReverseDepsToAdd.push_back(std::make_pair(NextI, I));
14641459 }
14651460 }
14661461
14791474 ReverseNonLocalPtrDepTy::iterator ReversePtrDepIt =
14801475 ReverseNonLocalPtrDeps.find(RemInst);
14811476 if (ReversePtrDepIt != ReverseNonLocalPtrDeps.end()) {
1482 SmallPtrSet &Set = ReversePtrDepIt->second;
14831477 SmallVector,8> ReversePtrDepsToAdd;
14841478
1485 for (SmallPtrSet::iterator I = Set.begin(),
1486 E = Set.end(); I != E; ++I) {
1487 ValueIsLoadPair P = *I;
1479 for (ValueIsLoadPair P : ReversePtrDepIt->second) {
14881480 assert(P.getPointer() != RemInst &&
14891481 "Already removed NonLocalPointerDeps info for RemInst");
14901482
15251517 DEBUG(verifyRemoved(RemInst));
15261518 }
15271519 /// verifyRemoved - Verify that the specified instruction does not occur
1528 /// in our internal data structures.
1520 /// in our internal data structures. This function verifies by asserting in
1521 /// debug builds.
15291522 void MemoryDependenceAnalysis::verifyRemoved(Instruction *D) const {
1523 #ifndef NDEBUG
15301524 for (LocalDepMapType::const_iterator I = LocalDeps.begin(),
15311525 E = LocalDeps.end(); I != E; ++I) {
15321526 assert(I->first != D && "Inst occurs in data structures");
15551549 for (ReverseDepMapType::const_iterator I = ReverseLocalDeps.begin(),
15561550 E = ReverseLocalDeps.end(); I != E; ++I) {
15571551 assert(I->first != D && "Inst occurs in data structures");
1558 for (SmallPtrSet::const_iterator II = I->second.begin(),
1559 EE = I->second.end(); II != EE; ++II)
1560 assert(*II != D && "Inst occurs in data structures");
1552 for (Instruction *Inst : I->second)
1553 assert(Inst != D && "Inst occurs in data structures");
15611554 }
15621555
15631556 for (ReverseDepMapType::const_iterator I = ReverseNonLocalDeps.begin(),
15641557 E = ReverseNonLocalDeps.end();
15651558 I != E; ++I) {
15661559 assert(I->first != D && "Inst occurs in data structures");
1567 for (SmallPtrSet::const_iterator II = I->second.begin(),
1568 EE = I->second.end(); II != EE; ++II)
1569 assert(*II != D && "Inst occurs in data structures");
1560 for (Instruction *Inst : I->second)
1561 assert(Inst != D && "Inst occurs in data structures");
15701562 }
15711563
15721564 for (ReverseNonLocalPtrDepTy::const_iterator
15741566 E = ReverseNonLocalPtrDeps.end(); I != E; ++I) {
15751567 assert(I->first != D && "Inst occurs in rev NLPD map");
15761568
1577 for (SmallPtrSet::const_iterator II = I->second.begin(),
1578 E = I->second.end(); II != E; ++II)
1579 assert(*II != ValueIsLoadPair(D, false) &&
1580 *II != ValueIsLoadPair(D, true) &&
1569 for (ValueIsLoadPair P : I->second)
1570 assert(P != ValueIsLoadPair(D, false) &&
1571 P != ValueIsLoadPair(D, true) &&
15811572 "Inst occurs in ReverseNonLocalPtrDeps map");
15821573 }
1583
1584 }
1574 #endif
1575 }
524524 MachineBasicBlock *Entry = MF->begin();
525525 SmallPtrSet Visited;
526526
527 for (df_ext_iterator >
528 DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited);
529 DFI != E; ++DFI) {
530 MachineBasicBlock *MBB = *DFI;
531
527 for (MachineBasicBlock *MBB : depth_first_ext(Entry, Visited)) {
532528 // Mark live-in registers as live-in.
533529 SmallVector Defs;
534530 for (MachineBasicBlock::livein_iterator II = MBB->livein_begin(),
150150 Changed |= EliminatePHINodes(MF, *I);
151151
152152 // Remove dead IMPLICIT_DEF instructions.
153 for (SmallPtrSet::iterator I = ImpDefs.begin(),
154 E = ImpDefs.end(); I != E; ++I) {
155 MachineInstr *DefMI = *I;
153 for (MachineInstr *DefMI : ImpDefs) {
156154 unsigned DefReg = DefMI->getOperand(0).getReg();
157155 if (MRI->use_nodbg_empty(DefReg)) {
158156 if (LIS)
710710 SmallPtrSet Reachable;
711711
712712 // Iterate over the reachable blocks in DFS order.
713 for (df_ext_iterator >
714 DFI = df_ext_begin(&Fn, Reachable), DFE = df_ext_end(&Fn, Reachable);
713 for (auto DFI = df_ext_begin(&Fn, Reachable), DFE = df_ext_end(&Fn, Reachable);
715714 DFI != DFE; ++DFI) {
716715 int SPAdj = 0;
717716 // Check the exit state of the DFS stack predecessor.
10931093 }
10941094
10951095 // Add the clobber lists for all the instructions we skipped earlier.
1096 for (SmallPtrSet::const_iterator
1097 I = SkippedInstrs.begin(), E = SkippedInstrs.end(); I != E; ++I)
1098 if (const uint16_t *Defs = (*I)->getImplicitDefs())
1096 for (const MCInstrDesc *Desc : SkippedInstrs)
1097 if (const uint16_t *Defs = Desc->getImplicitDefs())
10991098 while (*Defs)
11001099 MRI->setPhysRegUsed(*Defs++);
11011100
1192911929 // like register copies will interfere with trivial cases).
1193011930
1193111931 SmallVector Worklist;
11932 for (SmallPtrSet::iterator I = Visited.begin(),
11933 IE = Visited.end(); I != IE; ++I)
11934 if (*I != OriginalChain.getNode())
11935 Worklist.push_back(*I);
11932 for (const SDNode *N : Visited)
11933 if (N != OriginalChain.getNode())
11934 Worklist.push_back(N);
1193611935
1193711936 while (!Worklist.empty()) {
1193811937 const SDNode *M = Worklist.pop_back_val();
55535553 // new operands.
55545554 if (!DeadNodeSet.empty()) {
55555555 SmallVector DeadNodes;
5556 for (SmallPtrSet::iterator I = DeadNodeSet.begin(),
5557 E = DeadNodeSet.end(); I != E; ++I)
5558 if ((*I)->use_empty())
5559 DeadNodes.push_back(*I);
5556 for (SDNode *N : DeadNodeSet)
5557 if (N->use_empty())
5558 DeadNodes.push_back(N);
55605559 RemoveDeadNodes(DeadNodes);
55615560 }
55625561
350350 continue;
351351
352352 // Demote the PHIs to the stack.
353 for (SmallPtrSet::iterator I = PHIsToDemote.begin(),
354 E = PHIsToDemote.end();
355 I != E; ++I)
356 DemotePHIToStack(*I);
353 for (PHINode *PN : PHIsToDemote)
354 DemotePHIToStack(PN);
357355
358356 // Move the landingpad instruction back to the top of the landing pad block.
359357 LPI->moveBefore(UnwindBlock->begin());
6363 SmallPtrSet Reachable;
6464
6565 // Mark all reachable blocks.
66 for (df_ext_iterator > I =
67 df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable); I != E; ++I)
68 /* Mark all reachable blocks */;
66 for (BasicBlock *BB : depth_first_ext(&F, Reachable))
67 (void)BB/* Mark all reachable blocks */;
6968
7069 // Loop over all dead blocks, remembering them and deleting all instructions
7170 // in them.
124123 MachineLoopInfo *MLI = getAnalysisIfAvailable();
125124
126125 // Mark all reachable blocks.
127 for (df_ext_iterator >
128 I = df_ext_begin(&F, Reachable), E = df_ext_end(&F, Reachable);
129 I != E; ++I)
130 /* Mark all reachable blocks */;
126 for (MachineBasicBlock *BB : depth_first_ext(&F, Reachable))
127 (void)BB/* Mark all reachable blocks */;
131128
132129 // Loop over all dead blocks, remembering them and deleting all instructions
133130 // in them.
109109 MutexGuard guard(Lock);
110110 assert(JITs.size() != 0 && "No Jit registered");
111111 //search function in every instance of JIT
112 for (SmallPtrSet::const_iterator Jit = JITs.begin(),
113 end = JITs.end();
114 Jit != end; ++Jit) {
115 if (Function *F = (*Jit)->FindFunctionNamed(Name))
116 return (*Jit)->getPointerToFunction(F);
112 for (JIT *Jit : JITs) {
113 if (Function *F = Jit->FindFunctionNamed(Name))
114 return Jit->getPointerToFunction(F);
117115 }
118116 // The function is not available : fallback on the first created (will
119117 // search in symbol of the current program/library)
461461 if (F2C == FunctionToCallSitesMap.end())
462462 return;
463463 StubToResolverMapTy &S2RMap = *StubToResolverMap;
464 for (SmallPtrSet::const_iterator I = F2C->second.begin(),
465 E = F2C->second.end(); I != E; ++I) {
466 S2RMap.UnregisterStubResolver(*I);
467 bool Erased = CallSiteToFunctionMap.erase(*I);
464 for (void *C : F2C->second) {
465 S2RMap.UnregisterStubResolver(C);
466 bool Erased = CallSiteToFunctionMap.erase(C);
468467 (void)Erased;
469468 assert(Erased && "Missing call site->function mapping");
470469 }
572572 return;
573573
574574 SmallPtrSet &LU = DMI->second;
575 for (SmallPtrSet::iterator I = LU.begin(),
576 E = LU.end(); I != E; ++I) {
577 LastUses.push_back(*I);
575 for (Pass *LUP : LU) {
576 LastUses.push_back(LUP);
578577 }
579578
580579 }
69236923 // N.B. the order the invoke BBs are processed in doesn't matter here.
69246924 const MCPhysReg *SavedRegs = RI.getCalleeSavedRegs(MF);
69256925 SmallVector MBBLPads;
6926 for (SmallPtrSet::iterator
6927 I = InvokeBBs.begin(), E = InvokeBBs.end(); I != E; ++I) {
6928 MachineBasicBlock *BB = *I;
6926 for (MachineBasicBlock *BB : InvokeBBs) {
69296927
69306928 // Remove the landing pad successor from the invoke block and replace it
69316929 // with the new dispatch block.
323323 MachineBasicBlock *Entry = MF.begin();
324324
325325 bool Changed = false;
326 for (df_ext_iterator >
327 I = df_ext_begin(Entry, Processed), E = df_ext_end(Entry, Processed);
328 I != E; ++I)
329 Changed |= processBasicBlock(MF, **I);
326 for (MachineBasicBlock *BB : depth_first_ext(Entry, Processed))
327 Changed |= processBasicBlock(MF, *BB);
330328
331329 // Process any unreachable blocks in arbitrary order now.
332330 if (MF.size() != Processed.size())
476476 // loading block.
477477 for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
478478 BasicBlock *P = *PI;
479 for (idf_ext_iterator >
480 I = idf_ext_begin(P, TranspBlocks),
481 E = idf_ext_end(P, TranspBlocks); I != E; ++I)
482 if (AA.canBasicBlockModify(**I, Loc))
479 for (BasicBlock *TranspBB : inverse_depth_first_ext(P, TranspBlocks))
480 if (AA.canBasicBlockModify(*TranspBB, Loc))
483481 return false;
484482 }
485483 }
11141114 // that all inputs the to the PHI nodes are in the same equivalence sets.
11151115 // Check to verify that all operands of the PHIs are either PHIS that can be
11161116 // transformed, loads from GV, or MI itself.
1117 for (SmallPtrSet::const_iterator I = LoadUsingPHIs.begin()
1118 , E = LoadUsingPHIs.end(); I != E; ++I) {
1119 const PHINode *PN = *I;
1117 for (const PHINode *PN : LoadUsingPHIs) {
11201118 for (unsigned op = 0, e = PN->getNumIncomingValues(); op != e; ++op) {
11211119 Value *InVal = PN->getIncomingValue(op);
11221120
27102708 Eval.getMutatedMemory().begin(), E = Eval.getMutatedMemory().end();
27112709 I != E; ++I)
27122710 CommitValueTo(I->second, I->first);
2713 for (SmallPtrSet::const_iterator I =
2714 Eval.getInvariants().begin(), E = Eval.getInvariants().end();
2715 I != E; ++I)
2716 (*I)->setConstant(true);
2711 for (GlobalVariable *GV : Eval.getInvariants())
2712 GV->setConstant(true);
27172713 }
27182714
27192715 return EvalSuccess;
27672763 CompilerUsedV = collectUsedGlobalVariables(M, CompilerUsed, true);
27682764 }
27692765 typedef SmallPtrSet::iterator iterator;
2766 typedef iterator_range used_iterator_range;
27702767 iterator usedBegin() { return Used.begin(); }
27712768 iterator usedEnd() { return Used.end(); }
2769 used_iterator_range used() {
2770 return used_iterator_range(usedBegin(), usedEnd());
2771 }
27722772 iterator compilerUsedBegin() { return CompilerUsed.begin(); }
27732773 iterator compilerUsedEnd() { return CompilerUsed.end(); }
2774 used_iterator_range compilerUsed() {
2775 return used_iterator_range(compilerUsedBegin(), compilerUsedEnd());
2776 }
27742777 bool usedCount(GlobalValue *GV) const { return Used.count(GV); }
27752778 bool compilerUsedCount(GlobalValue *GV) const {
27762779 return CompilerUsed.count(GV);
28592862 bool Changed = false;
28602863 LLVMUsed Used(M);
28612864
2862 for (LLVMUsed::iterator I = Used.usedBegin(), E = Used.usedEnd(); I != E; ++I)
2863 Used.compilerUsedErase(*I);
2865 for (GlobalValue *GV : Used.used())
2866 Used.compilerUsedErase(GV);
28642867
28652868 for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
28662869 I != E;) {
147147 // we don't see references from function local inline assembly. To be
148148 // conservative, we internalize symbols in llvm.compiler.used, but we
149149 // keep llvm.compiler.used so that the symbol is not deleted by llvm.
150 for (SmallPtrSet::iterator I = Used.begin(), E = Used.end();
151 I != E; ++I) {
152 GlobalValue *V = *I;
150 for (GlobalValue *V : Used) {
153151 ExternalNames.insert(V->getName());
154152 }
155153
153153 C->destroyConstant();
154154
155155 // If the constant referenced anything, see if we can delete it as well.
156 for (SmallPtrSet::iterator OI = Operands.begin(),
157 OE = Operands.end(); OI != OE; ++OI)
158 RemoveDeadConstant(*OI);
156 for (Constant *O : Operands)
157 RemoveDeadConstant(O);
159158 }
160159
161160 // Strip the symbol table of its names.
245245 // Determine whether the original StartBB post-dominates all of the blocks we
246246 // visited. If not, insert a sentinal indicating that most optimizations are
247247 // not safe.
248 for (SmallPtrSet::const_iterator I = Visited.begin(),
249 E = Visited.end(); I != E; ++I) {
250 const BasicBlock *BB = *I;
248 for (const BasicBlock *BB : Visited) {
251249 if (BB == StartBB)
252250 continue;
253251 const TerminatorInst *TI = cast(&BB->back());
507507 // If this function has no escaping allocas or suspicious vararg usage,
508508 // objc_storeStrong calls can be marked with the "tail" keyword.
509509 if (TailOkForStoreStrongs)
510 for (SmallPtrSet::iterator I = StoreStrongCalls.begin(),
511 E = StoreStrongCalls.end(); I != E; ++I)
512 (*I)->setTailCall();
510 for (CallInst *CI : StoreStrongCalls)
511 CI->setTailCall();
513512 StoreStrongCalls.clear();
514513
515514 return Changed;
410410 // Merge the insert point sets. If there are any differences,
411411 // that makes this a partial merge.
412412 bool Partial = ReverseInsertPts.size() != Other.ReverseInsertPts.size();
413 for (SmallPtrSet::const_iterator
414 I = Other.ReverseInsertPts.begin(),
415 E = Other.ReverseInsertPts.end(); I != E; ++I)
416 Partial |= ReverseInsertPts.insert(*I);
413 for (Instruction *Inst : Other.ReverseInsertPts)
414 Partial |= ReverseInsertPts.insert(Inst);
417415 return Partial;
418416 }
419417
22982296 DEBUG(dbgs() << "== ObjCARCOpt::MoveCalls ==\n");
22992297
23002298 // Insert the new retain and release calls.
2301 for (SmallPtrSet::const_iterator
2302 PI = ReleasesToMove.ReverseInsertPts.begin(),
2303 PE = ReleasesToMove.ReverseInsertPts.end(); PI != PE; ++PI) {
2304 Instruction *InsertPt = *PI;
2299 for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) {
23052300 Value *MyArg = ArgTy == ParamTy ? Arg :
23062301 new BitCastInst(Arg, ParamTy, "", InsertPt);
23072302 Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
23122307 DEBUG(dbgs() << "Inserting new Retain: " << *Call << "\n"
23132308 "At insertion point: " << *InsertPt << "\n");
23142309 }
2315 for (SmallPtrSet::const_iterator
2316 PI = RetainsToMove.ReverseInsertPts.begin(),
2317 PE = RetainsToMove.ReverseInsertPts.end(); PI != PE; ++PI) {
2318 Instruction *InsertPt = *PI;
2310 for (Instruction *InsertPt : RetainsToMove.ReverseInsertPts) {
23192311 Value *MyArg = ArgTy == ParamTy ? Arg :
23202312 new BitCastInst(Arg, ParamTy, "", InsertPt);
23212313 Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Release);
23322324 }
23332325
23342326 // Delete the original retain and release calls.
2335 for (SmallPtrSet::const_iterator
2336 AI = RetainsToMove.Calls.begin(),
2337 AE = RetainsToMove.Calls.end(); AI != AE; ++AI) {
2338 Instruction *OrigRetain = *AI;
2327 for (Instruction *OrigRetain : RetainsToMove.Calls) {
23392328 Retains.blot(OrigRetain);
23402329 DeadInsts.push_back(OrigRetain);
23412330 DEBUG(dbgs() << "Deleting retain: " << *OrigRetain << "\n");
23422331 }
2343 for (SmallPtrSet::const_iterator
2344 AI = ReleasesToMove.Calls.begin(),
2345 AE = ReleasesToMove.Calls.end(); AI != AE; ++AI) {
2346 Instruction *OrigRelease = *AI;
2332 for (Instruction *OrigRelease : ReleasesToMove.Calls) {
23472333 Releases.erase(OrigRelease);
23482334 DeadInsts.push_back(OrigRelease);
23492335 DEBUG(dbgs() << "Deleting release: " << *OrigRelease << "\n");
23912377 KnownSafeTD &= NewRetainRRI.KnownSafe;
23922378 MultipleOwners =
23932379 MultipleOwners || MultiOwnersSet.count(GetObjCArg(NewRetain));
2394 for (SmallPtrSet::const_iterator
2395 LI = NewRetainRRI.Calls.begin(),
2396 LE = NewRetainRRI.Calls.end(); LI != LE; ++LI) {
2397 Instruction *NewRetainRelease = *LI;
2380 for (Instruction *NewRetainRelease : NewRetainRRI.Calls) {
23982381 DenseMap::const_iterator Jt =
23992382 Releases.find(NewRetainRelease);
24002383 if (Jt == Releases.end())
24402423
24412424 // Collect the optimal insertion points.
24422425 if (!KnownSafe)
2443 for (SmallPtrSet::const_iterator
2444 RI = NewRetainReleaseRRI.ReverseInsertPts.begin(),
2445 RE = NewRetainReleaseRRI.ReverseInsertPts.end();
2446 RI != RE; ++RI) {
2447 Instruction *RIP = *RI;
2426 for (Instruction *RIP : NewRetainReleaseRRI.ReverseInsertPts) {
24482427 if (ReleasesToMove.ReverseInsertPts.insert(RIP)) {
24492428 // If we overflow when we compute the path count, don't
24502429 // remove/move anything.
24752454 const RRInfo &NewReleaseRRI = It->second;
24762455 KnownSafeBU &= NewReleaseRRI.KnownSafe;
24772456 CFGHazardAfflicted |= NewReleaseRRI.CFGHazardAfflicted;
2478 for (SmallPtrSet::const_iterator
2479 LI = NewReleaseRRI.Calls.begin(),
2480 LE = NewReleaseRRI.Calls.end(); LI != LE; ++LI) {
2481 Instruction *NewReleaseRetain = *LI;
2457 for (Instruction *NewReleaseRetain : NewReleaseRRI.Calls) {
24822458 MapVector::const_iterator Jt =
24832459 Retains.find(NewReleaseRetain);
24842460 if (Jt == Retains.end())
25082484
25092485 // Collect the optimal insertion points.
25102486 if (!KnownSafe)
2511 for (SmallPtrSet::const_iterator
2512 RI = NewReleaseRetainRRI.ReverseInsertPts.begin(),
2513 RE = NewReleaseRetainRRI.ReverseInsertPts.end();
2514 RI != RE; ++RI) {
2515 Instruction *RIP = *RI;
2487 for (Instruction *RIP : NewReleaseRetainRRI.ReverseInsertPts) {
25162488 if (RetainsToMove.ReverseInsertPts.insert(RIP)) {
25172489 // If we overflow when we compute the path count, don't
25182490 // remove/move anything.
238238 LoopInfo &loopInfo = getAnalysis();
239239 SmallPtrSet blocks;
240240 blocks.insert(L->block_begin(), L->block_end());
241 for (SmallPtrSet::iterator I = blocks.begin(),
242 E = blocks.end(); I != E; ++I)
243 loopInfo.removeBlock(*I);
241 for (BasicBlock *BB : blocks)
242 loopInfo.removeBlock(BB);
244243
245244 // The last step is to inform the loop pass manager that we've
246245 // eliminated this loop.
13361336 }
13371337
13381338 // Update the RegTracker.
1339 for (SmallPtrSet::iterator I = OldRegs.begin(),
1340 E = OldRegs.end(); I != E; ++I)
1341 if (!Regs.count(*I))
1342 RegUses.DropRegister(*I, LUIdx);
1339 for (const SCEV *S : OldRegs)
1340 if (!Regs.count(S))
1341 RegUses.DropRegister(S, LUIdx);
13431342 }
13441343
13451344 void LSRUse::print(raw_ostream &OS) const {
22252224 // must dominate all the post-inc comparisons we just set up, and it must
22262225 // dominate the loop latch edge.
22272226 IVIncInsertPos = L->getLoopLatch()->getTerminator();
2228 for (SmallPtrSet::const_iterator I = PostIncs.begin(),
2229 E = PostIncs.end(); I != E; ++I) {
2227 for (Instruction *Inst : PostIncs) {
22302228 BasicBlock *BB =
22312229 DT.findNearestCommonDominator(IVIncInsertPos->getParent(),
2232 (*I)->getParent());
2233 if (BB == (*I)->getParent())
2234 IVIncInsertPos = *I;
2230 Inst->getParent());
2231 if (BB == Inst->getParent())
2232 IVIncInsertPos = Inst;
22352233 else if (BB != IVIncInsertPos->getParent())
22362234 IVIncInsertPos = BB->getTerminator();
22372235 }
25662564
25672565 if (!Users.empty()) {
25682566 DEBUG(dbgs() << "Chain: " << *Chain.Incs[0].UserInst << " users:\n";
2569 for (SmallPtrSet::const_iterator I = Users.begin(),
2570 E = Users.end(); I != E; ++I) {
2571 dbgs() << " " << **I << "\n";
2567 for (Instruction *Inst : Users) {
2568 dbgs() << " " << *Inst << "\n";
25722569 });
25732570 return false;
25742571 }
43014298 // reference that register in order to be considered. This prunes out
43024299 // unprofitable searching.
43034300 SmallSetVector ReqRegs;
4304 for (SmallPtrSet::const_iterator I = CurRegs.begin(),
4305 E = CurRegs.end(); I != E; ++I)
4306 if (LU.Regs.count(*I))
4307 ReqRegs.insert(*I);
4301 for (const SCEV *S : CurRegs)
4302 if (LU.Regs.count(S))
4303 ReqRegs.insert(S);
43084304
43094305 SmallPtrSet NewRegs;
43104306 Cost NewCost;
43494345 } else {
43504346 DEBUG(dbgs() << "New best at "; NewCost.print(dbgs());
43514347 dbgs() << ".\n Regs:";
4352 for (SmallPtrSet::const_iterator
4353 I = NewRegs.begin(), E = NewRegs.end(); I != E; ++I)
4354 dbgs() << ' ' << **I;
4348 for (const SCEV *S : NewRegs)
4349 dbgs() << ' ' << *S;
43554350 dbgs() << '\n');
43564351
43574352 SolutionCost = NewCost;
165165
166166 if (LoadInst *L = dyn_cast(Inst)) {
167167 AliasAnalysis::Location Loc = AA->getLocation(L);
168 for (SmallPtrSet::iterator I = Stores.begin(),
169 E = Stores.end(); I != E; ++I)
170 if (AA->getModRefInfo(*I, Loc) & AliasAnalysis::Mod)
168 for (Instruction *S : Stores)
169 if (AA->getModRefInfo(S, Loc) & AliasAnalysis::Mod)
171170 return false;
172171 }
173172
246246 // Append the clauses from the outer landing pad instruction into the inlined
247247 // landing pad instructions.
248248 LandingPadInst *OuterLPad = Invoke.getLandingPadInst();
249 for (SmallPtrSet::iterator I = InlinedLPads.begin(),
250 E = InlinedLPads.end(); I != E; ++I) {
251 LandingPadInst *InlinedLPad = *I;
249 for (LandingPadInst *InlinedLPad : InlinedLPads) {
252250 unsigned OuterNum = OuterLPad->getNumClauses();
253251 InlinedLPad->reserveClauses(OuterNum);
254252 for (unsigned OuterIdx = 0; OuterIdx != OuterNum; ++OuterIdx)
495495 }
496496
497497 // Delete each unique out-of-loop (and thus dead) predecessor.
498 for (SmallPtrSet::iterator I = BadPreds.begin(),
499 E = BadPreds.end(); I != E; ++I) {
498 for (BasicBlock *P : BadPreds) {
500499
501500 DEBUG(dbgs() << "LoopSimplify: Deleting edge from dead predecessor "
502 << (*I)->getName() << "\n");
501 << P->getName() << "\n");
503502
504503 // Inform each successor of each dead pred.
505 for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I); SI != SE; ++SI)
506 (*SI)->removePredecessor(*I);
504 for (succ_iterator SI = succ_begin(P), SE = succ_end(P); SI != SE; ++SI)
505 (*SI)->removePredecessor(P);
507506 // Zap the dead pred's terminator and replace it with unreachable.
508 TerminatorInst *TI = (*I)->getTerminator();
507 TerminatorInst *TI = P->getTerminator();
509508 TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
510 (*I)->getTerminator()->eraseFromParent();
511 new UnreachableInst((*I)->getContext(), *I);
509 P->getTerminator()->eraseFromParent();
510 new UnreachableInst(P->getContext(), P);
512511 Changed = true;
513512 }
514513 }
856856 less_second> IDFPriorityQueue;
857857 IDFPriorityQueue PQ;
858858
859 for (SmallPtrSet::const_iterator I = DefBlocks.begin(),
860 E = DefBlocks.end();
861 I != E; ++I) {
862 if (DomTreeNode *Node = DT.getNode(*I))
859 for (BasicBlock *BB : DefBlocks) {
860 if (DomTreeNode *Node = DT.getNode(BB))
863861 PQ.push(std::make_pair(Node, DomLevels[Node]));
864862 }
865863
311311 // have to take.
312312 std::vector > BlockInfo;
313313
314 for (SmallPtrSet::iterator I = Blocks.begin(),
315 E = Blocks.end(); I != E; ++I)
316 BlockInfo.push_back(std::make_pair((*I)->getParent()->getName(),
317 (*I)->getName()));
314 for (BasicBlock *BB : Blocks)
315 BlockInfo.push_back(std::make_pair(BB->getParent()->getName(),
316 BB->getName()));
318317
319318 // Now run the CFG simplify pass on the function...
320319 std::vector Passes;
419418 // Make sure to use instruction pointers that point into the now-current
420419 // module, and that they don't include any deleted blocks.
421420 Insts.clear();
422 for (SmallPtrSet::const_iterator I = Instructions.begin(),
423 E = Instructions.end(); I != E; ++I)
424 Insts.push_back(*I);
421 for (Instruction *Inst : Instructions)
422 Insts.push_back(Inst);
425423 return true;
426424 }
427425 delete M; // It didn't crash, try something else.
900900 FindI = SuperRegClasses.find(SubIdx);
901901 if (FindI == SuperRegClasses.end())
902902 return;
903 for (SmallPtrSet::const_iterator I =
904 FindI->second.begin(), E = FindI->second.end(); I != E; ++I)
905 Out.set((*I)->EnumValue);
903 for (CodeGenRegisterClass *RC : FindI->second)
904 Out.set(RC->EnumValue);
906905 }
907906
908907 // Populate a unique sorted list of units from a register set.