It's a bool, so treat it like one. Fixes a MSVC warning.
[oota-llvm.git] / lib / Analysis / ProfileEstimatorPass.cpp
index 8f5313fda79b2d69e784a4f3c5eafe314cecdd5b..ef72383710dc25728d1fc1ff5c6bf2a5c00ecba4 100644 (file)
@@ -168,9 +168,15 @@ void ProfileEstimatorPass::recurseBasicBlock(BasicBlock *BB) {
   std::set<BasicBlock*> ProcessedSuccs;
 
   // Otherwise consider weight of outgoing edges and store them for
-  // distribution of remaining weight.
-  for ( succ_iterator bbi = succ_begin(BB), bbe = succ_end(BB);
-        bbi != bbe; ++bbi ) {
+  // distribution of remaining weight. In case the block has no successors
+  // create a (BB,0) edge.
+  succ_iterator bbi = succ_begin(BB), bbe = succ_end(BB);
+  if (bbi == bbe) {
+    Edge edge = getEdge(BB,0);
+    EdgeInformation[BB->getParent()][edge] = BBWeight;
+    printEdgeWeight(edge);
+  }
+  for ( ; bbi != bbe; ++bbi ) {
     if (ProcessedSuccs.insert(*bbi).second) {
       Edge edge = getEdge(BB,*bbi);
       double w = getEdgeWeight(edge);