- int has_the_graph = FALSE;
- int i;
- int n_sub;
-
- if (eset_contains (_live_classes, clazz)) {
- int n_meth = get_class_n_members (clazz);
-
- for (i = 0; i < n_meth; i ++) {
- entity *member = get_class_member (clazz, i);
- if (is_method_type (get_entity_type (member))) {
- ir_graph *impl = get_entity_irg (member);
-
- if (impl == graph) {
- return (TRUE);
- }
- } /* is_method */
- } /* all methods */
- } /* _live_classes.contains (clazz) */
-
- /* our subclasses might be using that graph, no? */
- n_sub = get_class_n_subtypes (clazz);
- for (i = 0; !has_the_graph && (i < n_sub); i ++) {
- type *sub = get_class_subtype (clazz, i);
-
- has_the_graph |= has_graph (sub, graph);
- }
-
- return (has_the_graph);
+ int i;
+ int n_runs = 0;
+ bool rerun = true;
+
+ /* init_tables has added main_irg to _live_graphs */
+
+ /* Need to take care of graphs that are externally
+ visible or sticky. Pretend that they are called: */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *graph = get_irp_irg(i);
+ ir_entity *ent = get_irg_entity(graph);
+ ir_linkage linkage = get_entity_linkage(ent);
+
+ if (entity_is_externally_visible(ent)
+ || (linkage & IR_LINKAGE_HIDDEN_USER)) {
+ pset_new_insert(_live_graphs, graph);
+ }
+ }
+
+ while (rerun) {
+ ir_graph *graph;
+ pset_new_iterator_t iter;
+
+ /* start off new */
+ pset_new_t *live_graphs = _live_graphs;
+ _live_graphs = XMALLOC(pset_new_t);
+ pset_new_init(_live_graphs);
+
+ DB((dbg, LEVEL_2, "RTA: RUN %i\n", n_runs));
+
+ /* collect what we have found previously */
+ foreach_pset_new(live_graphs, graph, iter) {
+ pset_new_insert(_live_graphs, graph);
+ }
+
+ rerun = false;
+ foreach_pset_new(live_graphs, graph, iter) {
+ DB((dbg, LEVEL_2, "RTA: RUN %i: considering graph of %+F\n", n_runs, graph));
+ rerun |= rta_fill_graph(graph);
+ }
+ pset_new_destroy(live_graphs);
+ free(live_graphs);
+ ++n_runs;
+ }
+
+ return n_runs;