X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ffunccall.c;h=cb8e8c5305d2ef116f87c832be094f7b02ef9c96;hb=f274dcf35aa0d3f4748387dbddfe50e8d7d44951;hp=6b4e3942d9951cda22b7558e3fa1c5c44fe6d2e8;hpb=79d338a142a26da9cf87a2f2687ccae7e5bc5198;p=libfirm diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index 6b4e3942d..cb8e8c530 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -49,14 +49,13 @@ static void rem_mem_from_const_fkt_calls(ir_node *node, void *env) ptr = get_Call_ptr(call); if (get_irn_op(ptr) == op_SymConst && get_SymConst_kind(ptr) == symconst_addr_ent) { - ent = get_SymConst_entity(ptr); - if ((get_entity_additional_properties(ent) & irg_const_function) == 0) + if ((get_entity_additional_properties(ent) & mtp_property_const) == 0) return; ++ctx->n_calls_removed_SymConst; } - else if (get_irn_op(ptr) == op_Sel && + else if (is_Sel(ptr) && get_irg_callee_info_state(current_ir_graph) == irg_callee_info_consistent) { /* If all possible callees are real functions, we can remove the memory edge. */ int i, n_callees = get_Call_n_callees(call); @@ -67,8 +66,12 @@ static void rem_mem_from_const_fkt_calls(ir_node *node, void *env) return; for (i = 0; i < n_callees; ++i) { ent = get_Call_callee(call, i); - if ((get_entity_additional_properties(ent) & irg_const_function) == 0) - return; + if (ent == unknown_entity) { + /* we don't know which entity is called here */ + return; + } + if ((get_entity_additional_properties(ent) & mtp_property_const) == 0) + return; } ++ctx->n_calls_removed_Sel; } @@ -102,12 +105,15 @@ static void rem_mem_from_const_fkt_calls(ir_node *node, void *env) switch (get_Proj_proj(node)) { case pn_Call_M_regular: { ir_node *old_mem = get_irn_link(call); - if (old_mem) + if (old_mem) { exchange(node, old_mem); + ctx->changed = 1; + } } break; case pn_Call_X_except: case pn_Call_M_except: exchange(node, new_Bad()); + ctx->changed = 1; break; default: ; } @@ -123,7 +129,7 @@ void optimize_funccalls(int force_run) int change; unsigned num_pure = 0; - if (! get_opt_real_func_call()) + if (! get_opt_real_function_call()) return; /* first step: detect, which functions are const, i.e. do NOT touch any memory */ @@ -134,7 +140,7 @@ void optimize_funccalls(int force_run) change = 0; - if (get_irg_additional_properties(irg) & irg_const_function) { + if (get_irg_additional_properties(irg) & mtp_property_const) { /* already marked as a const function */ ++num_pure; } @@ -183,7 +189,7 @@ void optimize_funccalls(int force_run) if (! change) { /* no memory changes found, it's a const function */ - set_irg_additional_property(irg, irg_const_function); + set_irg_additional_property(irg, mtp_property_const); ++num_pure; } } @@ -200,13 +206,14 @@ void optimize_funccalls(int force_run) ir_graph *irg = get_irp_irg(i); /* no need to do this on const functions */ - if ((get_irg_additional_properties(irg) & irg_const_function) == 0) { + if ((get_irg_additional_properties(irg) & mtp_property_const) == 0) { ctx.changed = 0; irg_walk_graph(irg, NULL, rem_mem_from_const_fkt_calls, &ctx); if (ctx.changed) { - /* changes were done */ + /* changes were done including exception edges */ set_irg_outs_inconsistent(irg); + set_irg_doms_inconsistent(irg); set_irg_loopinfo_state(current_ir_graph, loopinfo_cf_inconsistent); } } @@ -224,44 +231,3 @@ void optimize_funccalls(int force_run) } } } - -/** - * Walker: Walks over all graphs and evaluates calls with - * constant arguments. - * Currently used only for non-virtual calls. - */ -static void eval_calls(ir_node *call, void *env) -{ - ir_node *ptr, *param; - entity *ent; - ir_graph *irg; - int i; - - if (get_irn_op(call) != op_Call) - return; - - ptr = get_Call_ptr(call); - - if (get_irn_op(ptr) != op_SymConst) - return; - - if (get_SymConst_kind(ptr) != symconst_addr_ent) - return; - - ent = get_SymConst_entity(ptr); - irg = get_entity_irg(ent); - - if (! irg) - return; - - /* ok, we found the called graph here, check for const args */ - for (i = get_Call_n_params(call) - 1; i >= 0; --i) { - param = get_Call_param(call, i); - - if (is_irn_constlike(param)) { - /* Found one: add to statistics */ - - ir_printf("%+F called with const %+F at position %d\n", ent, param, i); - } - } -}