post(irg, env);
}
-void callgraph_walk(ir_entity **roots, unsigned n_roots,
- callgraph_walk_func *pre, callgraph_walk_func *post, void *env) {
+void callgraph_walk(callgraph_walk_func *pre, callgraph_walk_func *post, void *env) {
int i, n_irgs = get_irp_n_irgs();
- unsigned r;
++master_cg_visited;
- for (r = 0; r < n_roots; ++r) {
- ir_graph *irg = get_entity_irg(roots[r]);
- if (irg == NULL)
- continue;
+ /* roots are methods which have no callers in the current program */
+ for (i = 0; i < n_irgs; ++i) {
+ ir_graph *irg = get_irp_irg(i);
- do_walk(irg, pre, post, env);
+ if (get_irg_n_callers(irg) == 0)
+ do_walk(irg, pre, post, env);
}
- /* cgana "optimizes" the graph instead of just analysing it so the
- * roots list isn't even correct anymore when passed to this method...
- * so we hack around this and search for more unreferenced/free
- * methods... */
+ /* in case of unreachable call loops we haven't visited some irgs yet */
for (i = 0; i < n_irgs; i++) {
ir_graph *irg = get_irp_irg(i);
- if (!cg_irg_visited(irg))
- do_walk(irg, pre, post, env);
+ do_walk(irg, pre, post, env);
}
}