mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Use auto iteration in lib/Transforms/Scalar/SampleProfile.cpp. No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220394 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -249,8 +249,8 @@ unsigned SampleProfileLoader::getBlockWeight(BasicBlock *B) { | |||||||
|  |  | ||||||
|   // Otherwise, compute and cache B's weight. |   // Otherwise, compute and cache B's weight. | ||||||
|   unsigned Weight = 0; |   unsigned Weight = 0; | ||||||
|   for (BasicBlock::iterator I = B->begin(), E = B->end(); I != E; ++I) { |   for (auto &I : B->getInstList()) { | ||||||
|     unsigned InstWeight = getInstWeight(*I); |     unsigned InstWeight = getInstWeight(I); | ||||||
|     if (InstWeight > Weight) |     if (InstWeight > Weight) | ||||||
|       Weight = InstWeight; |       Weight = InstWeight; | ||||||
|   } |   } | ||||||
| @@ -267,7 +267,7 @@ unsigned SampleProfileLoader::getBlockWeight(BasicBlock *B) { | |||||||
| bool SampleProfileLoader::computeBlockWeights(Function &F) { | bool SampleProfileLoader::computeBlockWeights(Function &F) { | ||||||
|   bool Changed = false; |   bool Changed = false; | ||||||
|   DEBUG(dbgs() << "Block weights\n"); |   DEBUG(dbgs() << "Block weights\n"); | ||||||
|   for (Function::iterator B = F.begin(), E = F.end(); B != E; ++B) { |   for (auto B = F.begin(), E = F.end(); B != E; ++B) { | ||||||
|     unsigned Weight = getBlockWeight(B); |     unsigned Weight = getBlockWeight(B); | ||||||
|     Changed |= (Weight > 0); |     Changed |= (Weight > 0); | ||||||
|     DEBUG(printBlockWeight(dbgs(), B)); |     DEBUG(printBlockWeight(dbgs(), B)); | ||||||
| @@ -302,9 +302,7 @@ bool SampleProfileLoader::computeBlockWeights(Function &F) { | |||||||
| void SampleProfileLoader::findEquivalencesFor( | void SampleProfileLoader::findEquivalencesFor( | ||||||
|     BasicBlock *BB1, SmallVector<BasicBlock *, 8> Descendants, |     BasicBlock *BB1, SmallVector<BasicBlock *, 8> Descendants, | ||||||
|     DominatorTreeBase<BasicBlock> *DomTree) { |     DominatorTreeBase<BasicBlock> *DomTree) { | ||||||
|   for (SmallVectorImpl<BasicBlock *>::iterator I = Descendants.begin(), |   for (auto I = Descendants.begin(), E = Descendants.end(); I != E; ++I) { | ||||||
|                                                E = Descendants.end(); |  | ||||||
|        I != E; ++I) { |  | ||||||
|     BasicBlock *BB2 = *I; |     BasicBlock *BB2 = *I; | ||||||
|     bool IsDomParent = DomTree->dominates(BB2, BB1); |     bool IsDomParent = DomTree->dominates(BB2, BB1); | ||||||
|     bool IsInSameLoop = LI->getLoopFor(BB1) == LI->getLoopFor(BB2); |     bool IsInSameLoop = LI->getLoopFor(BB1) == LI->getLoopFor(BB2); | ||||||
| @@ -340,7 +338,7 @@ void SampleProfileLoader::findEquivalenceClasses(Function &F) { | |||||||
|   SmallVector<BasicBlock *, 8> DominatedBBs; |   SmallVector<BasicBlock *, 8> DominatedBBs; | ||||||
|   DEBUG(dbgs() << "\nBlock equivalence classes\n"); |   DEBUG(dbgs() << "\nBlock equivalence classes\n"); | ||||||
|   // Find equivalence sets based on dominance and post-dominance information. |   // Find equivalence sets based on dominance and post-dominance information. | ||||||
|   for (Function::iterator B = F.begin(), E = F.end(); B != E; ++B) { |   for (auto B = F.begin(), E = F.end(); B != E; ++B) { | ||||||
|     BasicBlock *BB1 = B; |     BasicBlock *BB1 = B; | ||||||
|  |  | ||||||
|     // Compute BB1's equivalence class once. |     // Compute BB1's equivalence class once. | ||||||
| @@ -388,7 +386,7 @@ void SampleProfileLoader::findEquivalenceClasses(Function &F) { | |||||||
|   // each equivalence class has the largest weight, assign that weight |   // each equivalence class has the largest weight, assign that weight | ||||||
|   // to all the blocks in that equivalence class. |   // to all the blocks in that equivalence class. | ||||||
|   DEBUG(dbgs() << "\nAssign the same weight to all blocks in the same class\n"); |   DEBUG(dbgs() << "\nAssign the same weight to all blocks in the same class\n"); | ||||||
|   for (Function::iterator B = F.begin(), E = F.end(); B != E; ++B) { |   for (auto B = F.begin(), E = F.end(); B != E; ++B) { | ||||||
|     BasicBlock *BB = B; |     BasicBlock *BB = B; | ||||||
|     BasicBlock *EquivBB = EquivalenceClass[BB]; |     BasicBlock *EquivBB = EquivalenceClass[BB]; | ||||||
|     if (BB != EquivBB) |     if (BB != EquivBB) | ||||||
| @@ -432,7 +430,7 @@ unsigned SampleProfileLoader::visitEdge(Edge E, unsigned *NumUnknownEdges, | |||||||
| bool SampleProfileLoader::propagateThroughEdges(Function &F) { | bool SampleProfileLoader::propagateThroughEdges(Function &F) { | ||||||
|   bool Changed = false; |   bool Changed = false; | ||||||
|   DEBUG(dbgs() << "\nPropagation through edges\n"); |   DEBUG(dbgs() << "\nPropagation through edges\n"); | ||||||
|   for (Function::iterator BI = F.begin(), EI = F.end(); BI != EI; ++BI) { |   for (auto BI = F.begin(), EI = F.end(); BI != EI; ++BI) { | ||||||
|     BasicBlock *BB = BI; |     BasicBlock *BB = BI; | ||||||
|  |  | ||||||
|     // Visit all the predecessor and successor edges to determine |     // Visit all the predecessor and successor edges to determine | ||||||
| @@ -447,16 +445,16 @@ bool SampleProfileLoader::propagateThroughEdges(Function &F) { | |||||||
|  |  | ||||||
|       if (i == 0) { |       if (i == 0) { | ||||||
|         // First, visit all predecessor edges. |         // First, visit all predecessor edges. | ||||||
|         for (size_t I = 0; I < Predecessors[BB].size(); I++) { |         for (auto *Pred : Predecessors[BB]) { | ||||||
|           Edge E = std::make_pair(Predecessors[BB][I], BB); |           Edge E = std::make_pair(Pred, BB); | ||||||
|           TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge); |           TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge); | ||||||
|           if (E.first == E.second) |           if (E.first == E.second) | ||||||
|             SelfReferentialEdge = E; |             SelfReferentialEdge = E; | ||||||
|         } |         } | ||||||
|       } else { |       } else { | ||||||
|         // On the second round, visit all successor edges. |         // On the second round, visit all successor edges. | ||||||
|         for (size_t I = 0; I < Successors[BB].size(); I++) { |         for (auto *Succ : Successors[BB]) { | ||||||
|           Edge E = std::make_pair(BB, Successors[BB][I]); |           Edge E = std::make_pair(BB, Succ); | ||||||
|           TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge); |           TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
| @@ -534,7 +532,7 @@ bool SampleProfileLoader::propagateThroughEdges(Function &F) { | |||||||
| /// We are interested in unique edges. If a block B1 has multiple | /// We are interested in unique edges. If a block B1 has multiple | ||||||
| /// edges to another block B2, we only add a single B1->B2 edge. | /// edges to another block B2, we only add a single B1->B2 edge. | ||||||
| void SampleProfileLoader::buildEdges(Function &F) { | void SampleProfileLoader::buildEdges(Function &F) { | ||||||
|   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { |   for (auto I = F.begin(), E = F.end(); I != E; ++I) { | ||||||
|     BasicBlock *B1 = I; |     BasicBlock *B1 = I; | ||||||
|  |  | ||||||
|     // Add predecessors for B1. |     // Add predecessors for B1. | ||||||
| @@ -596,7 +594,7 @@ void SampleProfileLoader::propagateWeights(Function &F) { | |||||||
|   // edge weights computed during propagation. |   // edge weights computed during propagation. | ||||||
|   DEBUG(dbgs() << "\nPropagation complete. Setting branch weights\n"); |   DEBUG(dbgs() << "\nPropagation complete. Setting branch weights\n"); | ||||||
|   MDBuilder MDB(F.getContext()); |   MDBuilder MDB(F.getContext()); | ||||||
|   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { |   for (auto I = F.begin(), E = F.end(); I != E; ++I) { | ||||||
|     BasicBlock *B = I; |     BasicBlock *B = I; | ||||||
|     TerminatorInst *TI = B->getTerminator(); |     TerminatorInst *TI = B->getTerminator(); | ||||||
|     if (TI->getNumSuccessors() == 1) |     if (TI->getNumSuccessors() == 1) | ||||||
| @@ -638,10 +636,9 @@ void SampleProfileLoader::propagateWeights(Function &F) { | |||||||
| /// \returns a valid DISubprogram, if found. Otherwise, it returns an empty | /// \returns a valid DISubprogram, if found. Otherwise, it returns an empty | ||||||
| /// DISubprogram. | /// DISubprogram. | ||||||
| static const DISubprogram getDISubprogram(Function &F, const LLVMContext &Ctx) { | static const DISubprogram getDISubprogram(Function &F, const LLVMContext &Ctx) { | ||||||
|   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { |   for (auto I = F.begin(), E = F.end(); I != E; ++I) { | ||||||
|     BasicBlock *B = I; |     BasicBlock *B = I; | ||||||
|     for (BasicBlock::iterator BI = B->begin(), BE = B->end(); BI != BE; ++BI) { |     for (auto &Inst : B->getInstList()) { | ||||||
|       Instruction &Inst = *BI; |  | ||||||
|       DebugLoc DLoc = Inst.getDebugLoc(); |       DebugLoc DLoc = Inst.getDebugLoc(); | ||||||
|       if (DLoc.isUnknown()) |       if (DLoc.isUnknown()) | ||||||
|         continue; |         continue; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user