fixed some warnings
[libfirm] / ir / ir / iredges.c
index af8b08d..2b6e19d 100644 (file)
@@ -397,11 +397,12 @@ void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir
        }
 
        if (edges_activated_kind(irg, EDGE_KIND_BLOCK) && is_Block(src)) {
-               ir_node *bl_old = old_tgt ? get_nodes_block(skip_Proj(old_tgt)) : NULL;
+               /* do not use get_nodes_block() here, it fails when running unpinned */
+               ir_node *bl_old = old_tgt ? get_irn_n(skip_Proj(old_tgt), -1) : NULL;
                ir_node *bl_tgt = NULL;
 
                if (tgt)
-                       bl_tgt = is_Bad(tgt) ? tgt : get_nodes_block(skip_Proj(tgt));
+                       bl_tgt = is_Bad(tgt) ? tgt : get_irn_n(skip_Proj(tgt), -1);
 
                edges_notify_edge_kind(src, pos, bl_tgt, bl_old, EDGE_KIND_BLOCK, irg);
        }
@@ -837,3 +838,38 @@ void dump_all_out_edges(ir_node *irn)
                }
        }
 }
+
+static void irg_block_edges_walk2(ir_node *bl,
+                                irg_walk_func *pre, irg_walk_func *post,
+                                void *env) {
+       const ir_edge_t *edge, *next;
+
+       if (Block_not_block_visited(bl)) {
+               mark_Block_block_visited(bl);
+
+               if (pre)
+                       pre(bl, env);
+
+               foreach_out_edge_kind_safe(bl, edge, next, EDGE_KIND_BLOCK) {
+                       /* find the corresponding successor block. */
+                       ir_node *pred = get_edge_src_irn(edge);
+                       irg_block_edges_walk2(pred, pre, post, env);
+               }
+
+               if (post)
+                       post(bl, env);
+       }
+}
+
+/* Walks only over Block nodes in the graph.  Has it's own visited
+   flag, so that it can be interleaved with the other walker.         */
+void irg_block_edges_walk(ir_node *node,
+                          irg_walk_func *pre, irg_walk_func *post,
+                          void *env) {
+
+       assert(edges_activated(current_ir_graph));
+       assert(is_Block(node));
+
+       inc_irg_block_visited(current_ir_graph);
+       irg_block_edges_walk2(node, pre, post, env);
+}