+ foreach_ir_edgeset(edges, e, iter) {
+ if (! e->invalid && ! e->present && bitset_is_set(w.reachable, get_irn_idx(e->src))) {
+ w.problem_found = 1;
+ ir_fprintf(stderr, "Edge Verifier: edge(%ld) %+F,%d is superfluous\n", edge_get_id(e), e->src, e->pos);
+ }
+ }
+
+ return w.problem_found;
+}
+
+#define IGNORE_NODE(irn) (is_Bad((irn)) || is_Block((irn)))
+
+/**
+ * Clear link field of all nodes.
+ */
+static void clear_links(ir_node *irn, void *env)
+{
+ bitset_t *bs;
+ ir_graph *irg;
+ (void) env;
+
+ if (IGNORE_NODE(irn)) {
+ set_irn_link(irn, NULL);
+ return;
+ }
+
+ irg = get_irn_irg(irn);
+ bs = bitset_malloc(get_irg_last_idx(irg));
+ set_irn_link(irn, bs);
+}
+
+/**
+ * Increases count (stored in link field) for all operands of a node.
+ */
+static void count_user(ir_node *irn, void *env)
+{
+ int i;
+ int first;
+ (void) env;
+
+ first = is_Block(irn) ? 0 : -1;
+ for (i = get_irn_arity(irn) - 1; i >= first; --i) {
+ ir_node *op = get_irn_n(irn, i);
+ bitset_t *bs = (bitset_t*)get_irn_link(op);
+
+ if (bs)
+ bitset_set(bs, get_irn_idx(irn));
+ }
+}
+
+/**
+ * Verifies if collected count, number of edges in list and stored edge count are in sync.
+ */
+static void verify_edge_counter(ir_node *irn, void *env)
+{
+ build_walker *w = (build_walker*)env;
+ bitset_t *bs;
+ int list_cnt;
+ int ref_cnt;
+ int edge_cnt;
+ size_t idx;
+ const struct list_head *head;
+ const struct list_head *pos;
+ ir_graph *irg;
+
+ if (IGNORE_NODE(irn))
+ return;
+
+ bs = (bitset_t*)get_irn_link(irn);
+ list_cnt = 0;
+ ref_cnt = 0;
+ edge_cnt = _get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
+ head = _get_irn_outs_head(irn, EDGE_KIND_NORMAL);
+
+ /* We can iterate safely here, list heads have already been verified. */
+ list_for_each(pos, head) {
+ ++list_cnt;
+ }
+
+ /* check all nodes that reference us and count edges that point number
+ * of ins that actually point to us */
+ irg = get_irn_irg(irn);
+ ref_cnt = 0;
+ bitset_foreach(bs, idx) {
+ int i, arity;
+ ir_node *src = get_idx_irn(irg, idx);
+
+ arity = get_irn_arity(src);
+ for (i = 0; i < arity; ++i) {
+ ir_node *in = get_irn_n(src, i);
+ if (in == irn)
+ ++ref_cnt;
+ }