Fixed typos, improved docu
[libfirm] / ir / ana / irextbb.c
index 7c3db0a..5d95912 100644 (file)
@@ -71,7 +71,6 @@ static void addto_extblk(ir_extblk *extblk, ir_node *block)
  * we are interested only in 1, 2 and >2.
  */
 static int get_block_n_succs(ir_node *block) {
-#ifdef FIRM_EDGES_INPLACE
   if (edges_activated(current_ir_graph)) {
     const ir_edge_t *edge;
 
@@ -84,7 +83,6 @@ static int get_block_n_succs(ir_node *block) {
     edge = get_block_succ_next(block, edge);
     return edge ? 3 : 2;
   }
-#endif
   return get_Block_n_cfg_outs(block);
 }
 
@@ -274,14 +272,10 @@ void compute_extbb(ir_graph *irg) {
   env.obst = irg->extbb_obst;
   env.head = NULL;
 
-#ifdef FIRM_EDGES_INPLACE
-  if (edges_activated(irg)) {
-    /* we have edges */
+  if (! edges_activated(irg)) {
+    /* we don't have edges */
+    assure_irg_outs(irg);
   }
-  else
-#endif
-  if (get_irg_outs_state(irg) != outs_consistent)
-    compute_irg_outs(irg);
 
   /* we must mark nodes, so increase the visited flag */
   inc_irg_visited(irg);
@@ -431,16 +425,22 @@ static void irg_extblock_walk_2(ir_extblk *blk, extbb_walk_func *pre, extbb_walk
    flag, so that it can be interleaved with the other walker.         */
 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env)
 {
-  ir_node *pred;
+  ir_node *pred, *start_bl = get_irg_start_block(current_ir_graph);
+  ir_extblk *start_blk = get_Block_extbb(start_bl);
   int i;
 
   assert(blk);
   assert(!get_interprocedural_view());   /* interprocedural_view not implemented */
   inc_irg_block_visited(current_ir_graph);
+
+  /* assure the start block is the first one */
+  mark_extbb_visited(start_blk);
+  if (post)
+    post(start_blk, env);
   irg_extblock_walk_2(blk, pre, post, env);
 
   /* keepalive: the endless loops ... */
-  if (get_extbb_leader(blk) == get_irg_end_block(current_ir_graph)) {
+  if (blk == get_Block_extbb(get_irg_end_block(current_ir_graph))) {
     ir_node *node = get_irg_end(current_ir_graph);
     int arity = get_irn_arity(node);
     for (i = 0; i < arity; i++) {
@@ -457,6 +457,9 @@ void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *po
       }
     }
   }
+
+  if (pre)
+    pre(start_blk, env);
 }
 
 /* Walks only over reachable Extended Basic Block nodes in the graph. */