Use C++ ranged 'for' for AllSuccessorIter use
authorBruce Forstall <brucefo@microsoft.com>
Tue, 18 Apr 2017 00:13:25 +0000 (17:13 -0700)
committerBruce Forstall <brucefo@microsoft.com>
Thu, 20 Apr 2017 16:52:36 +0000 (09:52 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/71d36aa8ce864f0730e91b2242cf04b5bd411fb4

src/coreclr/src/jit/dataflow.h
src/coreclr/src/jit/flowgraph.cpp
src/coreclr/src/jit/liveness.cpp
src/coreclr/src/jit/lsra.cpp
src/coreclr/src/jit/ssabuilder.cpp
src/coreclr/src/jit/valuenum.cpp

index c9803a0..615a5d1 100644 (file)
@@ -70,11 +70,9 @@ void DataFlow::ForwardAnalysis(TCallback& callback)
 
         if (callback.EndMerge(block))
         {
-            AllSuccessorIter succsBegin = block->GetAllSuccs(m_pCompiler).begin();
-            AllSuccessorIter succsEnd   = block->GetAllSuccs(m_pCompiler).end();
-            for (AllSuccessorIter succ = succsBegin; succ != succsEnd; ++succ)
+            for (BasicBlock* succ : block->GetAllSuccs(m_pCompiler))
             {
-                worklist.insert(worklist.end(), *succ);
+                worklist.insert(worklist.end(), succ);
             }
         }
     }
index c385155..8ee2397 100644 (file)
@@ -12618,10 +12618,8 @@ bool Compiler::fgMightHaveLoop()
     {
         BitVecOps::AddElemD(&blockVecTraits, blocksSeen, block->bbNum);
 
-        AllSuccessorIter succsEnd = block->GetAllSuccs(this).end();
-        for (AllSuccessorIter succs = block->GetAllSuccs(this).begin(); succs != succsEnd; ++succs)
+        for (BasicBlock* succ : block->GetAllSuccs(this))
         {
-            BasicBlock* succ = (*succs);
             if (BitVecOps::IsMember(&blockVecTraits, blocksSeen, succ->bbNum))
             {
                 return true;
index 47950ae..d498a6f 100644 (file)
@@ -1167,12 +1167,10 @@ class LiveVarAnalysis
         }
 
         // Additionally, union in all the live-in tracked vars of successors.
-        AllSuccessorIter succsEnd = block->GetAllSuccs(m_compiler).end();
-        for (AllSuccessorIter succs = block->GetAllSuccs(m_compiler).begin(); succs != succsEnd; ++succs)
+        for (BasicBlock* succ : block->GetAllSuccs(m_compiler))
         {
-            BasicBlock* succ = (*succs);
             VarSetOps::UnionD(m_compiler, m_liveOut, succ->bbLiveIn);
-            m_memoryLiveOut |= (*succs)->bbMemoryLiveIn;
+            m_memoryLiveOut |= succ->bbMemoryLiveIn;
             if (succ->bbNum <= block->bbNum)
             {
                 m_hasPossibleBackEdge = true;
index 5576140..d8b5279 100644 (file)
@@ -4698,11 +4698,11 @@ void LinearScan::buildIntervals()
         {
             VarSetOps::DiffD(compiler, expUseSet, nextBlock->bbLiveIn);
         }
-        AllSuccessorIter succsEnd = block->GetAllSuccs(compiler).end();
-        for (AllSuccessorIter succs = block->GetAllSuccs(compiler).begin();
-             succs != succsEnd && !VarSetOps::IsEmpty(compiler, expUseSet); ++succs)
+        for (BasicBlock* succ : block->GetAllSuccs(compiler))
         {
-            BasicBlock* succ = (*succs);
+            if (VarSetOps::IsEmpty(compiler, expUseSet))
+                break;
+
             if (isBlockVisited(succ))
             {
                 continue;
index 3d74234..5cbe12a 100644 (file)
@@ -1391,11 +1391,8 @@ void SsaBuilder::BlockRenameVariables(BasicBlock* block, SsaRenameState* pRename
  */
 void SsaBuilder::AssignPhiNodeRhsVariables(BasicBlock* block, SsaRenameState* pRenameState)
 {
-    BasicBlock::AllSuccs allSuccs    = block->GetAllSuccs(m_pCompiler);
-    AllSuccessorIter     allSuccsEnd = allSuccs.end();
-    for (AllSuccessorIter allSuccsIter = allSuccs.begin(); allSuccsIter != allSuccsEnd; ++allSuccsIter)
+    for (BasicBlock* succ : block->GetAllSuccs(m_pCompiler))
     {
-        BasicBlock* succ = (*allSuccsIter);
         // Walk the statements for phi nodes.
         for (GenTreePtr stmt = succ->bbTreeList; stmt != nullptr && stmt->IsPhiDefnStmt(); stmt = stmt->gtNext)
         {
index 03bc204..5b40122 100644 (file)
@@ -4371,10 +4371,8 @@ struct ValueNumberState
 
         SetVisitBit(blk->bbNum, BVB_complete);
 
-        AllSuccessorIter succsEnd = blk->GetAllSuccs(m_comp).end();
-        for (AllSuccessorIter succs = blk->GetAllSuccs(m_comp).begin(); succs != succsEnd; ++succs)
+        for (BasicBlock* succ : blk->GetAllSuccs(m_comp))
         {
-            BasicBlock* succ = (*succs);
 #ifdef DEBUG_VN_VISIT
             JITDUMP("   Succ(BB%02u).\n", succ->bbNum);
 #endif // DEBUG_VN_VISIT