cache another dereferenced iterator
authorGabor Greif <ggreif@gmail.com>
Thu, 15 Jul 2010 10:19:23 +0000 (10:19 +0000)
committerGabor Greif <ggreif@gmail.com>
Thu, 15 Jul 2010 10:19:23 +0000 (10:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108421 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ProfileInfo.cpp

index 38dcd2580e7968db075319f900f4d83c38eddb34..8d2712fd6e063e7ccfdd893699536e03d1eb557e 100644 (file)
@@ -71,22 +71,24 @@ ProfileInfoT<Function,BasicBlock>::getExecutionCount(const BasicBlock *BB) {
 
   // Are there zero predecessors of this block?
   if (PI == PE) {
-    Edge e = getEdge(0,BB);
+    Edge e = getEdge(0, BB);
     Count = getEdgeWeight(e);
   } else {
     // Otherwise, if there are predecessors, the execution count of this block is
     // the sum of the edge frequencies from the incoming edges.
     std::set<const BasicBlock*> ProcessedPreds;
     Count = 0;
-    for (; PI != PE; ++PI)
-      if (ProcessedPreds.insert(*PI).second) {
-        double w = getEdgeWeight(getEdge(*PI, BB));
+    for (; PI != PE; ++PI) {
+      const BasicBlock *P = *PI;
+      if (ProcessedPreds.insert(P).second) {
+        double w = getEdgeWeight(getEdge(P, BB));
         if (w == MissingValue) {
           Count = MissingValue;
           break;
         }
         Count += w;
       }
+    }
   }
 
   // If the predecessors did not suffice to get block weight, try successors.