-/* Compute the backedges that represent recursions. */
-void find_callgraph_recursions(void) {
- int i, n_irgs = get_irp_n_irgs();
-
- reset_isbe();
-
- /* -- Compute the looptree -- */
-
- /* The outermost graph. We start here. Then we start at all
- functions in irg list that are never called, then at the remaining
- unvisited ones. */
- assert(get_irp_main_irg());
- outermost_ir_graph = get_irp_main_irg();
- init_scc();
-
- current_loop = NULL;
- new_loop(); /* sets current_loop */
-
- master_cg_visited++;
- cgscc(outermost_ir_graph);
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (!cg_irg_visited(irg) && get_irg_n_callers(irg) == 0)
- cgscc(irg);
- }
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (!cg_irg_visited(irg))
- cgscc(irg);
- }
- irp->outermost_cg_loop = current_loop;
-
- /* -- Reverse the backedge information. -- */
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- int j, n_callees = get_irg_n_callees(irg);
- for (j = 0; j < n_callees; ++j) {
- if (is_irg_callee_backedge(irg, j))
- set_irg_caller_backedge(get_irg_callee(irg, j), irg);
- }
- }
-
- /* -- Schleifentiefe berechnen -- */
- int current_nesting = 0;
- master_cg_visited += 2;
- compute_loop_depth(get_irp_main_irg(), ¤t_nesting);
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (!cg_irg_visited(irg) && get_irg_n_callers(irg) == 0)
- compute_loop_depth(irg, ¤t_nesting);
- }
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (get_cg_irg_visited(irg) < master_cg_visited-1)
- compute_loop_depth(irg, ¤t_nesting);
- }
-
- /* -- Rekursionstiefe berechnen -- */
- ana_entry2 e;
- e.loop_stack = NEW_ARR_F(ir_loop *, 0);
- e.tos = 0;
- e.recursion_nesting = 0;
-
- master_cg_visited += 2;
- compute_rec_depth(get_irp_main_irg(), &e);
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (!cg_irg_visited(irg) && get_irg_n_callers(irg) == 0)
- compute_rec_depth(irg, &e);
- }
- for (i = 0; i < n_irgs; i++) {
- ir_graph *irg = get_irp_irg(i);
- if (get_cg_irg_visited(irg) < master_cg_visited-1)
- compute_rec_depth(irg, &e);
- }
-
- DEL_ARR_F(e.loop_stack);
-
- //dump_callgraph("-with_nesting");
-
- //dump_callgraph_loop_tree(current_loop, "-after_cons");
- irp->callgraph_state = irp_callgraph_and_calltree_consistent;
-}