+ node_t *node;
+
+ /* for each node with affinity edges */
+ co_gs_foreach_node(ienv->co, node) {
+ struct obstack ob;
+ neighb_t *nbr;
+ ir_node *center = node->irn;
+ ir_node **nodes;
+ set *edges;
+ int i, o, n_nodes, n_edges;
+
+ obstack_init(&ob);
+ edges = new_set(compare_edge_t, 8);
+
+ /* get all affinity neighbours */
+ n_nodes = 0;
+ co_gs_foreach_neighb(node, nbr) {
+ obstack_ptr_grow(&ob, nbr->irn);
+ ++n_nodes;
+ }
+ nodes = obstack_finish(&ob);
+
+ /* get all interference edges between these */
+ n_edges = 0;
+ for (i=0; i<n_nodes; ++i)
+ for (o=0; o<i; ++o)
+ if (be_ifg_connected(ienv->co->cenv->ifg, nodes[i], nodes[o]))
+ add_edge(edges, nodes[i], nodes[o], &n_edges);
+
+ /* cover all these interference edges with maximal cliques */
+ while (n_edges) {
+ edge_t *e;
+ pset *clique = pset_new_ptr(8);
+ int growed;
+
+ /* get 2 starting nodes to form a clique */
+ for (e=set_first(edges); !e->n1; e=set_next(edges))
+ /*nothing*/ ;
+
+ remove_edge(edges, e->n1, e->n2, &n_edges);
+ pset_insert_ptr(clique, e->n1);
+ pset_insert_ptr(clique, e->n2);
+
+ /* while the clique is growing */
+ do {
+ growed = 0;
+
+ /* search for a candidate to extend the clique */
+ for (i=0; i<n_nodes; ++i) {
+ ir_node *member, *cand = nodes[i];
+ int is_cand;
+
+ /* if its already in the clique try the next */
+ if (pset_find_ptr(clique, cand))
+ continue;
+
+ /* are there all necessary interferences? */
+ is_cand = 1;
+ pset_foreach(clique, member) {
+ if (!find_edge(edges, cand, member)) {
+ is_cand = 0;
+ pset_break(clique);
+ break;
+ }
+ }
+
+ /* now we know if we have a clique extender */
+ if (is_cand) {
+ /* first remove all covered edges */
+ pset_foreach(clique, member)
+ remove_edge(edges, cand, member, &n_edges);
+
+ /* insert into clique */
+ pset_insert_ptr(clique, cand);
+ growed = 1;
+ break;
+ }
+ }
+ } while (growed);