+ FILE *f;
+ set *edges = env->edges;
+ ir_graph *irg = env->irg;
+ char filename[128];
+
+ ir_snprintf(filename, sizeof(filename), "ifg_%s_%F.dot", env->cls->name, irg);
+
+ if((f = fopen(filename, "wt")) != NULL) {
+ bitset_pos_t pos;
+ int n_edges = 0;
+ if_edge_t *edge;
+ bitset_t *bs = bitset_malloc(get_graph_node_count(irg));
+
+ ir_fprintf(f, "graph \"%F\" {\n", irg);
+ fprintf(f, "\tnode [shape=box,style=filled]\n");
+
+ for(edge = set_first(edges); edge; edge = set_next(edges)) {
+ bitset_set(bs, edge->src);
+ bitset_set(bs, edge->tgt);
+ n_edges++;
+ }
+
+ fprintf(f, "\tx [label=\"nodes: %u, edges: %d\"]\n", bitset_popcnt(bs), n_edges);
+
+ bitset_foreach(bs, pos) {
+ int nr = (int) pos;
+ ir_node *irn = get_irn_for_graph_nr(irg, nr);
+
+ ir_fprintf(f, "\tn%d [label=\"%+F\"]\n", nr, irn);
+ }
+
+ for(edge = set_first(edges); edge; edge = set_next(edges)) {
+ fprintf(f, "\tn%d -- n%d [len=5]\n", edge->src, edge->tgt);
+ }
+
+ fprintf(f, "}\n");
+ fclose(f);
+
+ bitset_free(bs);
+ }
+
+}
+
+#endif /* DUMP_IFG */
+
+#endif /* BUILD_GRAPH */
+
+static void check_border_list(struct list_head *head)
+{
+ border_t *x;
+ list_for_each_entry(border_t, x, head, list) {
+ assert(x->magic == BORDER_FOURCC);
+ }
+}
+
+static void check_heads(be_chordal_env_t *env)
+{
+ pmap_entry *ent;
+ for(ent = pmap_first(env->border_heads); ent; ent = pmap_next(env->border_heads)) {
+ /* ir_printf("checking border list of block %+F\n", ent->key); */
+ check_border_list(ent->value);
+ }
+}
+
+
+/**
+ * Add an interval border to the list of a block's list
+ * of interval border.
+ * @note You always have to create the use before the def.
+ * @param env The environment.
+ * @param head The list head to enqueue the borders.
+ * @param irn The node (value) the border belongs to.
+ * @param pressure The pressure at this point in time.
+ * @param step A time step for the border.
+ * @param is_def Is the border a use or a def.
+ * @return The created border.
+ */
+static INLINE border_t *border_add(be_chordal_env_t *env, struct list_head *head,
+ ir_node *irn, unsigned step, unsigned pressure,
+ unsigned is_def, unsigned is_real)
+{
+ border_t *b;
+
+ if(!is_def) {
+ border_t *def;
+
+ b = obstack_alloc(&env->obst, sizeof(*b));
+
+ /* also allocate the def and tie it to the use. */
+ def = obstack_alloc(&env->obst, sizeof(*def));
+ memset(def, 0, sizeof(*def));
+ b->other_end = def;
+ def->other_end = b;
+
+ /*
+ * Set the link field of the irn to the def.
+ * This strongly relies on the fact, that the use is always
+ * made before the def.
+ */
+ set_irn_link(irn, def);
+
+ b->magic = BORDER_FOURCC;
+ def->magic = BORDER_FOURCC;
+ }
+
+ /*
+ * If the def is encountered, the use was made and so was the
+ * the def node (see the code above). It was placed into the
+ * link field of the irn, so we can get it there.
+ */
+ else {
+ b = get_irn_link(irn);
+
+ assert(b && b->magic == BORDER_FOURCC && "Illegal border encountered");
+ }
+
+ b->pressure = pressure;