X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_inline.c;h=f376c752dcc7d567c27fc1c13d9979d0292f4cef;hb=4c96713146f32c2b3fefcd9c21151487b2ca6033;hp=38b176361db211ff7669f473f7cb42fc7a3a6364;hpb=4377f9bab6b511699c50ba4e8eaf1b5abcf30a68;p=libfirm diff --git a/ir/opt/opt_inline.c b/ir/opt/opt_inline.c index 38b176361..f376c752d 100644 --- a/ir/opt/opt_inline.c +++ b/ir/opt/opt_inline.c @@ -1663,7 +1663,7 @@ static int calc_inline_benefice(ir_node *call, ir_graph *callee) { weight += 5 * n_params; } - /* constant parameters improve the benefiz */ + /* constant parameters improve the benefice */ for (i = 0; i < n_params; ++i) { ir_node *param = get_Call_param(call, i); @@ -1672,7 +1672,7 @@ static int calc_inline_benefice(ir_node *call, ir_graph *callee) { } callee_env = get_irg_link(callee); - if (callee_env->n_callers_orig == 1) { + if (callee_env->n_callers_orig == 1 && callee != current_ir_graph) { /* we are the only caller, give big bonus */ weight += 5000; } @@ -1680,9 +1680,9 @@ static int calc_inline_benefice(ir_node *call, ir_graph *callee) { /* do not inline big functions */ weight -= callee_env->n_nodes; - /* reduce the benefiz if the current function is already big */ + /* reduce the benefice if the current function is already big */ curr_env = get_irg_link(current_ir_graph); - weight -= curr_env->n_nodes >> 5; + weight -= curr_env->n_nodes / 100; /* give a bonus for functions with one block */ if (callee_env->n_blocks == 1) @@ -1753,6 +1753,10 @@ void inline_functions(int inline_threshold) { call = entry->call; callee = entry->callee; + /* calculate the benifice on the original call to prevent excessive inlining */ + benefice = calc_inline_benefice(call, callee); + DB((dbg, SET_LEVEL_2, "In %+F Call %+F has benefice %d\n", current_ir_graph, callee, benefice)); + e = pmap_find(copied_graphs, callee); if (e != NULL) { /* @@ -1762,10 +1766,7 @@ void inline_functions(int inline_threshold) { callee = e->value; } - benefice = calc_inline_benefice(call, callee); - DB((dbg, SET_LEVEL_2, "In %+F Call %+F has benefiz %d\n", current_ir_graph, call, benefice)); - - if (benefice > inline_threshold || + if (benefice > -inline_threshold || (get_irg_inline_property(callee) >= irg_inline_forced)) { if (current_ir_graph == callee) { /*