2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Always available outs.
23 * @author Sebastian Hack, Michael Beck, Andreas Schoesser
27 * This are out-edges (also called def-use edges) that are dynamically
28 * updated as the graph changes.
36 #include "iredgekinds.h"
37 #include "iredges_t.h"
47 #include "iredgeset.h"
52 #define HashSet ir_edgeset_t
53 #define HashSetIterator ir_edgeset_iterator_t
54 #define ValueType ir_edge_t*
55 #define NullValue NULL
56 #define DeletedValue ((ir_edge_t*)-1)
57 #define Hash(this,key) (HASH_PTR(key->src) ^ key->pos)
58 #define KeysEqual(this,key1,key2) ((key1->src) == (key2->src) && (key1->pos == key2->pos))
59 #define SetRangeEmpty(ptr,size) memset(ptr, 0, (size) * sizeof((ptr)[0]))
61 #define hashset_init ir_edgeset_init
62 #define hashset_init_size ir_edgeset_init_size
63 #define hashset_destroy ir_edgeset_destroy
64 #define hashset_insert ir_edgeset_insert
65 #define hashset_remove ir_edgeset_remove
66 #define hashset_find ir_edgeset_find
67 #define hashset_size ir_edgeset_size
68 #define hashset_iterator_init ir_edgeset_iterator_init
69 #define hashset_iterator_next ir_edgeset_iterator_next
70 #define hashset_remove_iterator ir_edgeset_remove_iterator
75 * A function that allows for setting an edge.
76 * This abstraction is necessary since different edge kind have
77 * different methods of setting edges.
79 typedef void (set_edge_func_t)(ir_node *src, int pos, ir_node *tgt);
81 typedef int (get_edge_src_arity_func_t)(const ir_node *src);
83 typedef ir_node *(get_edge_src_n_func_t)(const ir_node *src, int pos);
86 * Additional data for an edge kind.
89 const char *name; /**< name of this edge kind */
90 set_edge_func_t *set_edge; /**< the set_edge function */
91 int first_idx; /**< index of the first possible edge */
92 get_edge_src_arity_func_t *get_arity; /**< the get_arity function */
93 get_edge_src_n_func_t *get_n; /**< the get_n function */
94 } ir_edge_kind_info_t;
97 * Get the predecessor block.
99 static ir_node *get_block_n(const ir_node *irn, int pos) {
101 return get_Block_cfgpred_block(irn, pos);
106 static const ir_edge_kind_info_t edge_kind_info[EDGE_KIND_LAST] = {
107 { "normal" , set_irn_n, -1, get_irn_arity, get_irn_n },
108 { "block succs", NULL, 0, get_irn_arity, get_block_n },
109 { "dependency", set_irn_dep, 0, get_irn_deps, get_irn_dep }
112 #define foreach_tgt(irn, i, n, kind) for(i = edge_kind_info[kind].first_idx, n = edge_kind_info[kind].get_arity(irn); i < n; ++i)
113 #define get_n(irn, pos, kind) (edge_kind_info[kind].get_n(irn, pos))
114 #define get_kind_str(kind) (edge_kind_info[kind].name)
116 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
119 * This flag is set to 1, if the edges get initialized for an irg.
120 * Then register additional data is forbidden.
122 static int edges_used = 0;
125 * Summed size of all users private data
128 static int edges_private_size = 0;
129 #define EDGE_SIZE (sizeof(ir_edge_t) + edges_private_size)
132 * If set to 1, the list heads are checked every time an edge is changed.
134 static int edges_dbg = 0;
137 /* a static variable holding the last number assigned to a new edge */
138 static long last_edge_num = -1;
141 static INLINE long edge_get_id(const ir_edge_t *e) {
144 #else /* DEBUG_libfirm */
146 #endif /* DEBUG_libfirm */
150 * Announce to reserve extra space for each edge to be allocated.
152 * @param n: Size of the space to reserve
154 * @return Offset at which the private data will begin
156 * Several users can reserve extra space for private usage.
157 * Each user has to remember his given offset and the size of his private data.
158 * To be called before FIRM is initialized.
160 int edges_register_private_data(size_t n) {
161 int res = edges_private_size;
163 assert(!edges_used && "you cannot register private edge data, if edges have been initialized");
165 edges_private_size += n;
170 * Reset the user's private data at offset 'offset'
171 * The user has to remember his offset and the size of his data!
172 * Caution: Using wrong values here can destroy other users private data!
174 void edges_reset_private_data(ir_graph *irg, int offset, size_t size) {
175 irg_edge_info_t *info = _get_irg_edge_info(irg, EDGE_KIND_NORMAL);
177 ir_edgeset_iterator_t iter;
179 foreach_ir_edgeset(&info->edges, edge, iter) {
180 memset(edge + sizeof(*edge) + offset, 0, size);
184 #define TIMES37(x) (((x) << 5) + ((x) << 2) + (x))
186 #define get_irn_out_list_head(irn) (&get_irn_out_info(irn)->outs)
188 #define edge_hash(edge) (TIMES37((edge)->pos) + HASH_PTR((edge)->src))
191 * Initialize the out information for a graph.
192 * @note Dead node elimination can call this on an already initialized graph.
194 void edges_init_graph_kind(ir_graph *irg, ir_edge_kind_t kind) {
195 if (edges_activated_kind(irg, kind)) {
196 irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
200 if(info->allocated) {
201 amount = ir_edgeset_size(&info->edges);
202 ir_edgeset_destroy(&info->edges);
203 obstack_free(&info->edges_obst, NULL);
205 obstack_init(&info->edges_obst);
206 ir_edgeset_init_size(&info->edges, amount);
212 * Get the edge object of an outgoing edge at a node.
213 * @param irg The graph, the node is in.
214 * @param src The node at which the edge originates.
215 * @param pos The position of the edge.
216 * @return The corresponding edge object or NULL,
217 * if no such edge exists.
219 const ir_edge_t *get_irn_edge_kind(ir_graph *irg, const ir_node *src, int pos, ir_edge_kind_t kind)
221 if (edges_activated_kind(irg, kind)) {
222 irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
225 key.src = (ir_node *)src;
228 return ir_edgeset_find(&info->edges, &key);
235 * Get the edge object of an outgoing edge at a node.
236 * Looks for an edge for all kinds.
238 const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *src, int pos) {
239 const ir_edge_t *edge;
240 if((edge = get_irn_edge_kind(irg, src, pos, EDGE_KIND_NORMAL)) == NULL)
241 edge = get_irn_edge_kind(irg, src, pos, EDGE_KIND_BLOCK);
246 * Change the out count
248 * @param tgt the edge target
249 * @param kind the kind of the edge
251 static INLINE void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs) {
252 irn_edge_info_t *info = _get_irn_edge_info(tgt, kind);
253 info->out_count += ofs;
256 assert(info->out_count >= 0);
257 if (info->out_count == 0 && kind == EDGE_KIND_NORMAL) {
258 /* tgt lost it's last user */
261 for (i = get_irn_arity(tgt) - 1; i >= -1; --i) {
262 ir_node *prev = get_irn_n(tgt, i);
264 edges_notify_edge(tgt, i, NULL, prev, current_ir_graph);
266 for (i = get_irn_deps(tgt) - 1; i >= 0; --i) {
267 ir_node *prev = get_irn_dep(tgt, i);
269 edges_notify_edge_kind(tgt, i, NULL, prev, EDGE_KIND_DEP, current_ir_graph);
277 * Verify the edge list of a node, ie. ensure it's a loop:
278 * head -> e_1 -> ... -> e_n -> head
280 static INLINE void vrfy_list_head(ir_node *irn, ir_edge_kind_t kind) {
283 pset *lh_set = pset_new_ptr(16);
284 const struct list_head *head = _get_irn_outs_head(irn, kind);
285 const struct list_head *pos;
287 list_for_each(pos, head) {
288 if (pset_find_ptr(lh_set, pos)) {
289 const ir_edge_t *edge = list_entry(pos, ir_edge_t, list);
291 ir_fprintf(stderr, "EDGE Verifier: edge list broken (self loop not to head) for %+F:\n", irn);
292 fprintf(stderr, "- at list entry %d\n", num);
294 fprintf(stderr, "- edge(%ld) is invalid\n", edge_get_id(edge));
296 ir_fprintf(stderr, "- edge(%ld) %+F(%d)\n", edge_get_id(edge), edge->src, edge->pos);
301 pset_insert_ptr(lh_set, pos);
309 /* The edge from (src, pos) -> old_tgt is redirected to tgt */
310 void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt,
311 ir_node *old_tgt, ir_edge_kind_t kind,
314 const char *msg = "";
315 irg_edge_info_t *info;
320 assert(edges_activated_kind(irg, kind));
323 * Only do something, if the old and new target differ.
328 info = _get_irg_edge_info(irg, kind);
329 edges = &info->edges;
331 /* Initialize the edge template to search in the set. */
336 * If the target is NULL, the edge shall be deleted.
339 /* search the edge in the set. */
340 edge = ir_edgeset_find(edges, &templ);
342 /* mark the edge invalid if it was found */
345 list_del(&edge->list);
351 #endif /* DEBUG_libfirm */
352 edge_change_cnt(old_tgt, kind, -1);
355 /* If the edge was not found issue a warning on the debug stream */
357 msg = "edge to delete not found!\n";
362 * The target is not NULL and the old target differs
363 * from the new target, the edge shall be moved (if the
364 * old target was != NULL) or added (if the old target was
368 struct list_head *head = _get_irn_outs_head(tgt, kind);
370 assert(head->next && head->prev &&
371 "target list head must have been initialized");
373 /* If the old target is not null, the edge is moved. */
375 edge = ir_edgeset_find(edges, &templ);
376 assert(edge && "edge to redirect not found!");
377 assert(! edge->invalid && "Invalid edge encountered");
381 list_move(&edge->list, head);
382 edge_change_cnt(old_tgt, kind, -1);
385 /* The old target was null, thus, the edge is newly created. */
389 = obstack_alloc(&info->edges_obst, EDGE_SIZE);
390 memset(edge, 0, EDGE_SIZE);
394 DEBUG_ONLY(edge->src_nr = get_irn_node_nr(src));
396 new_edge = ir_edgeset_insert(edges, edge);
397 if(new_edge != edge) {
398 obstack_free(&info->edges_obst, edge);
401 assert(! edge->invalid && "Freshly inserted edge is invalid?!?");
402 assert(edge->list.next == NULL && edge->list.prev == NULL &&
403 "New edge must not have list head initialized");
406 list_add(&edge->list, head);
408 edge->edge_nr = ++last_edge_num;
409 #endif /* DEBUG_libfirm */
412 edge_change_cnt(tgt, kind, +1);
415 #ifndef DEBUG_libfirm
416 /* verify list heads */
419 vrfy_list_head(tgt, kind);
421 vrfy_list_head(old_tgt, kind);
425 DBG((dbg, LEVEL_5, "announce out edge: %+F %d-> %+F(%+F): %s\n", src, pos, tgt, old_tgt, msg));
428 void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg)
430 if (edges_activated_kind(irg, EDGE_KIND_NORMAL)) {
431 edges_notify_edge_kind(src, pos, tgt, old_tgt, EDGE_KIND_NORMAL, irg);
434 if (edges_activated_kind(irg, EDGE_KIND_BLOCK) && is_Block(src)) {
436 /* a MacroBlock edge: ignore it here */
438 ir_node *bl_old = old_tgt ? get_nodes_block(skip_Proj(old_tgt)) : NULL;
439 ir_node *bl_tgt = NULL;
442 bl_tgt = is_Bad(tgt) ? tgt : get_nodes_block(skip_Proj(tgt));
444 edges_notify_edge_kind(src, pos, bl_tgt, bl_old, EDGE_KIND_BLOCK, irg);
450 * Delete all in edges of a given kind from the node old.
452 * @param old the node
453 * @param kind the kind of edges to remove
454 * @param irg the irg of the old node
456 static void edges_node_deleted_kind(ir_node *old, ir_edge_kind_t kind, ir_graph *irg)
460 if (!edges_activated_kind(irg, kind))
463 DBG((dbg, LEVEL_5, "node deleted (kind: %s): %+F\n", get_kind_str(kind), old));
465 foreach_tgt(old, i, n, kind) {
466 ir_node *old_tgt = get_n(old, i, kind);
467 edges_notify_edge_kind(old, i, NULL, old_tgt, kind, irg);
471 struct build_walker {
475 unsigned problem_found;
479 * Post-Walker: notify all edges
481 static void build_edges_walker(ir_node *irn, void *data) {
482 struct build_walker *w = data;
484 ir_edge_kind_t kind = w->kind;
485 ir_graph *irg = w->irg;
486 get_edge_src_n_func_t *get_n;
488 if (! edges_activated_kind(irg, kind))
491 get_n = edge_kind_info[kind].get_n;
492 foreach_tgt(irn, i, n, kind) {
493 ir_node *pred = get_n(irn, i, kind);
494 edges_notify_edge_kind(irn, i, pred, NULL, kind, irg);
499 * Pre-Walker: initializes the list-heads and set the out-count
502 static void init_lh_walker(ir_node *irn, void *data) {
503 struct build_walker *w = data;
504 ir_edge_kind_t kind = w->kind;
505 INIT_LIST_HEAD(_get_irn_outs_head(irn, kind));
506 _get_irn_edge_info(irn, kind)->out_count = 0;
510 * Visitor: initializes the list-heads and set the out-count
511 * of all nodes to 0 of nodes that are not seen so far.
513 static void visitor(ir_node *irn, void *data) {
514 if (irn_not_visited(irn)) {
515 mark_irn_visited(irn);
516 init_lh_walker(irn, data);
521 * Build the initial edge set.
522 * Beware, this is not a simple task because it suffers from two
524 * - the anchor set allows access to Nodes that may not be reachable from
526 * - the identities add nodes to the "root set" that are not yet reachable
527 * from End. However, after some transformations, the CSE may revival these
530 * These problems can be fixed using different strategies:
531 * - Add an age flag to every node. Whenever the edge of a node is older
532 * then the current edge, invalidate the edges of this node.
533 * While this would help for revivaled nodes, it increases memory and runtime.
534 * - Delete the identities set.
535 * Solves the revival problem, but may increase the memory consumption, as
536 * nodes cannot be revivaled at all.
537 * - Manually iterate over the identities root set. This did not consume more memory
538 * but increase the computation time because the |identities| >= |V|
540 * Currently, we use the last option.
542 void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
544 struct build_walker w;
545 irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
551 edges_init_graph_kind(irg, kind);
552 irg_walk_anchors(irg, init_lh_walker, build_edges_walker, &w);
553 visit_all_identities(irg, visitor, &w);
556 void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
558 irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
561 if (info->allocated) {
562 obstack_free(&info->edges_obst, NULL);
563 ir_edgeset_destroy(&info->edges);
568 int (edges_activated_kind)(const ir_graph *irg, ir_edge_kind_t kind)
570 return _edges_activated_kind(irg, kind);
575 * Reroute all use-edges from a node to another.
576 * @param from The node whose use-edges shall be withdrawn.
577 * @param to The node to which all the use-edges of @p from shall be
579 * @param irg The graph.
581 void edges_reroute_kind(ir_node *from, ir_node *to, ir_edge_kind_t kind, ir_graph *irg)
583 set_edge_func_t *set_edge = edge_kind_info[kind].set_edge;
585 if(set_edge && edges_activated_kind(irg, kind)) {
586 struct list_head *head = _get_irn_outs_head(from, kind);
588 DBG((dbg, LEVEL_5, "reroute from %+F to %+F\n", from, to));
590 while (head != head->next) {
591 ir_edge_t *edge = list_entry(head->next, ir_edge_t, list);
592 assert(edge->pos >= -1);
593 set_edge(edge->src, edge->pos, to);
598 static void verify_set_presence(ir_node *irn, void *data)
600 struct build_walker *w = data;
601 ir_edgeset_t *edges = &_get_irg_edge_info(w->irg, w->kind)->edges;
604 foreach_tgt(irn, i, n, w->kind) {
610 e = ir_edgeset_find(edges, &templ);
614 w->problem_found = 1;
616 ir_fprintf(stderr, "Edge Verifier: edge %+F,%d -> %+F (kind: \"%s\") is missing\n",
617 irn, i, get_n(irn, i, w->kind), get_kind_str(w->kind));
623 static void verify_list_presence(ir_node *irn, void *data)
625 struct build_walker *w = data;
628 bitset_set(w->reachable, get_irn_idx(irn));
630 /* check list heads */
631 vrfy_list_head(irn, w->kind);
633 foreach_out_edge_kind(irn, e, w->kind) {
636 if (w->kind == EDGE_KIND_NORMAL && get_irn_arity(e->src) <= e->pos) {
637 w->problem_found = 1;
639 ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F -> %+F recorded at src position %d, but src has arity %d\n",
640 edge_get_id(e), e->src, irn, e->pos, get_irn_arity(e->src));
645 tgt = get_n(e->src, e->pos, w->kind);
648 w->problem_found = 1;
650 ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F,%d (kind \"%s\") is no out edge of %+F but of %+F\n",
651 edge_get_id(e), e->src, e->pos, get_kind_str(w->kind), irn, tgt);
657 int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind)
659 struct build_walker w;
660 ir_edgeset_t *edges = &_get_irg_edge_info(irg, kind)->edges;
662 ir_edgeset_iterator_t iter;
666 w.reachable = bitset_alloca(get_irg_last_idx(irg));
669 /* Clear the present bit in all edges available. */
670 foreach_ir_edgeset(edges, e, iter) {
674 irg_walk_graph(irg, verify_set_presence, verify_list_presence, &w);
677 * Dump all edges which are not invalid and not present.
678 * These edges are superfluous and their presence in the
681 foreach_ir_edgeset(edges, e, iter) {
682 if (! e->invalid && ! e->present && bitset_is_set(w.reachable, get_irn_idx(e->src))) {
684 ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F,%d is superfluous\n", edge_get_id(e), e->src, e->pos);
688 return w.problem_found;
691 #define IGNORE_NODE(irn) (is_Bad((irn)) || is_Block((irn)))
694 * Clear link field of all nodes.
696 static void clear_links(ir_node *irn, void *env) {
697 struct build_walker *w = env;
700 if (IGNORE_NODE(irn)) {
701 set_irn_link(irn, NULL);
705 bs = bitset_malloc(get_irg_last_idx(w->irg));
706 set_irn_link(irn, bs);
710 * Increases count (stored in link field) for all operands of a node.
712 static void count_user(ir_node *irn, void *env) {
718 for (i = get_irn_arity(irn) - 1; i >= first; --i) {
719 ir_node *op = get_irn_n(irn, i);
720 bitset_t *bs = get_irn_link(op);
723 bitset_set(bs, get_irn_idx(irn));
728 * Verifies if collected count, number of edges in list and stored edge count are in sync.
730 static void verify_edge_counter(ir_node *irn, void *env) {
731 struct build_walker *w = env;
737 const struct list_head *head;
738 const struct list_head *pos;
740 if (IGNORE_NODE(irn))
743 bs = get_irn_link(irn);
746 edge_cnt = _get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
747 head = _get_irn_outs_head(irn, EDGE_KIND_NORMAL);
749 /* We can iterate safely here, list heads have already been verified. */
750 list_for_each(pos, head) {
754 /* check all nodes that reference us and count edges that point number
755 * of ins that actually point to us */
757 bitset_foreach(bs, idx) {
759 ir_node *src = get_idx_irn(w->irg, idx);
761 arity = get_irn_arity(src);
762 for (i = 0; i < arity; ++i) {
763 ir_node *in = get_irn_n(src, i);
769 if (edge_cnt != list_cnt) {
770 w->problem_found = 1;
771 ir_fprintf(stderr, "Edge Verifier: edge count is %d, but %d edge(s) are recorded in list at %+F\n",
772 edge_cnt, list_cnt, irn);
775 if (ref_cnt != list_cnt) {
776 w->problem_found = 1;
777 ir_fprintf(stderr, "Edge Verifier: %+F reachable by %d node(s), but the list contains %d edge(s)\n",
778 irn, ref_cnt, list_cnt);
780 /* Matze: buggy if a node has multiple ins pointing at irn */
782 list_for_each(pos, head) {
783 ir_edge_t *edge = list_entry(pos, ir_edge_t, list);
784 bitset_flip(bs, get_irn_idx(edge->src));
787 if (ref_cnt < list_cnt)
788 fprintf(stderr," following nodes are recorded in list, but not as user:\n");
790 fprintf(stderr," following nodes are user, but not recorded in list:\n");
793 bitset_foreach(bs, idx) {
794 ir_node *src = get_idx_irn(w->irg, idx);
795 ir_fprintf(stderr, " %+F", src);
797 fprintf(stderr, "\n");
805 * Verifies the out edges of an irg.
807 int edges_verify(ir_graph *irg) {
808 struct build_walker w;
809 int problem_found = 0;
811 /* verify normal edges only */
812 problem_found = edges_verify_kind(irg, EDGE_KIND_NORMAL);
815 w.kind = EDGE_KIND_NORMAL;
819 irg_walk_anchors(irg, clear_links, count_user, &w);
820 irg_walk_anchors(irg, NULL, verify_edge_counter, &w);
822 return problem_found ? 1 : w.problem_found;
825 void init_edges(void) {
826 FIRM_DBG_REGISTER(dbg, DBG_EDGES);
827 /* firm_dbg_set_mask(dbg, -1); */
830 void edges_init_dbg(int do_dbg) {
834 void edges_activate(ir_graph *irg) {
835 edges_activate_kind(irg, EDGE_KIND_NORMAL);
836 edges_activate_kind(irg, EDGE_KIND_BLOCK);
839 void edges_deactivate(ir_graph *irg) {
840 edges_deactivate_kind(irg, EDGE_KIND_NORMAL);
841 edges_deactivate_kind(irg, EDGE_KIND_BLOCK);
844 int edges_assure(ir_graph *irg) {
845 int activated = edges_activated(irg);
853 int edges_assure_kind(ir_graph *irg, ir_edge_kind_t kind) {
854 int activated = edges_activated_kind(irg, kind);
857 edges_activate_kind(irg, kind);
862 void edges_node_deleted(ir_node *irn, ir_graph *irg) {
863 edges_node_deleted_kind(irn, EDGE_KIND_NORMAL, irg);
864 edges_node_deleted_kind(irn, EDGE_KIND_BLOCK, irg);
868 const ir_edge_t *(get_irn_out_edge_first_kind)(const ir_node *irn, ir_edge_kind_t kind) {
869 return _get_irn_out_edge_first_kind(irn, kind);
872 const ir_edge_t *(get_irn_out_edge_next)(const ir_node *irn, const ir_edge_t *last) {
873 return _get_irn_out_edge_next(irn, last);
876 ir_node *(get_edge_src_irn)(const ir_edge_t *edge) {
877 return _get_edge_src_irn(edge);
880 int (get_edge_src_pos)(const ir_edge_t *edge) {
881 return _get_edge_src_pos(edge);
884 int (get_irn_n_edges_kind)(const ir_node *irn, ir_edge_kind_t kind) {
885 return _get_irn_n_edges_kind(irn, kind);
888 void dump_all_out_edges(ir_node *irn) {
890 for (i = 0; i < EDGE_KIND_LAST; ++i) {
891 const ir_edge_t *edge;
893 printf("kind \"%s\"\n", get_kind_str(i));
894 foreach_out_edge_kind(irn, edge, i) {
895 ir_printf("\t%+F(%d)\n", edge->src, edge->pos);
900 static void irg_block_edges_walk2(ir_node *bl,
901 irg_walk_func *pre, irg_walk_func *post,
903 const ir_edge_t *edge, *next;
905 if (Block_not_block_visited(bl)) {
906 mark_Block_block_visited(bl);
911 foreach_out_edge_kind_safe(bl, edge, next, EDGE_KIND_BLOCK) {
912 /* find the corresponding successor block. */
913 ir_node *pred = get_edge_src_irn(edge);
914 irg_block_edges_walk2(pred, pre, post, env);
922 void irg_block_edges_walk(ir_node *node,
923 irg_walk_func *pre, irg_walk_func *post,
926 assert(edges_activated(current_ir_graph));
927 assert(is_Block(node));
929 set_using_block_visited(current_ir_graph);
931 inc_irg_block_visited(current_ir_graph);
932 irg_block_edges_walk2(node, pre, post, env);
934 clear_using_block_visited(current_ir_graph);