X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ffunccall.c;h=a5cddd6f8f33e5bf4b92bdd49d06c3d7cd2fe5a6;hb=1d523ad26cd541494c1e6cd8dc4b0736f0adc2cf;hp=ad2e295f87bd17dd6b6646361a477f01c64edfba;hpb=1ff0ced64d65a6a30aaa98fa5a7f34545df8a967;p=libfirm diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index ad2e295f8..a5cddd6f8 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -21,7 +21,6 @@ * @file * @brief Optimization of function calls. * @author Michael Beck - * @version $Id$ */ #include "config.h" @@ -89,8 +88,8 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) /* set the link to NULL for all non-const/pure calls */ set_irn_link(call, NULL); ptr = get_Call_ptr(call); - if (is_Global(ptr)) { - ent = get_Global_entity(ptr); + if (is_SymConst_addr_ent(ptr)) { + ent = get_SymConst_entity(ptr); prop = get_entity_additional_properties(ent); if ((prop & (mtp_property_const|mtp_property_pure)) == 0) @@ -113,7 +112,7 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) or_prop = 0; for (i = 0; i < n_callees; ++i) { ent = get_Call_callee(call, i); - if (ent == unknown_entity) { + if (is_unknown_entity(ent)) { /* we don't know which entity is called here */ return; } @@ -225,7 +224,7 @@ static void fix_const_call_lists(ir_graph *irg, env_t *ctx) } case pn_Call_X_except: exc_changed = 1; - exchange(proj, get_irg_bad(irg)); + exchange(proj, new_r_Bad(irg, mode_X)); break; case pn_Call_X_regular: { ir_node *block = get_nodes_block(call); @@ -238,13 +237,10 @@ static void fix_const_call_lists(ir_graph *irg, env_t *ctx) } } - /* changes were done ... */ - set_irg_outs_inconsistent(irg); - set_irg_loopinfo_state(irg, loopinfo_cf_inconsistent); - if (exc_changed) { /* ... including exception edges */ - set_irg_doms_inconsistent(irg); + clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE + | IR_GRAPH_STATE_CONSISTENT_LOOPINFO); } } /* fix_const_call_list */ @@ -265,8 +261,8 @@ static void collect_nothrow_calls(ir_node *node, void *env) /* set the link to NULL for all non-const/pure calls */ set_irn_link(call, NULL); ptr = get_Call_ptr(call); - if (is_Global(ptr)) { - ent = get_Global_entity(ptr); + if (is_SymConst_addr_ent(ptr)) { + ent = get_SymConst_entity(ptr); prop = get_entity_additional_properties(ent); if ((prop & mtp_property_nothrow) == 0) @@ -288,7 +284,7 @@ static void collect_nothrow_calls(ir_node *node, void *env) prop = mtp_property_nothrow; for (i = 0; i < n_callees; ++i) { ent = get_Call_callee(call, i); - if (ent == unknown_entity) { + if (is_unknown_entity(ent)) { /* we don't know which entity is called here */ return; } @@ -360,7 +356,7 @@ static void fix_nothrow_call_list(ir_graph *irg, ir_node *call_list, ir_node *pr switch (get_Proj_proj(proj)) { case pn_Call_X_except: exc_changed = 1; - exchange(proj, get_irg_bad(irg)); + exchange(proj, new_r_Bad(irg, mode_X)); break; case pn_Call_X_regular: { ir_node *block = get_nodes_block(call); @@ -374,12 +370,10 @@ static void fix_nothrow_call_list(ir_graph *irg, ir_node *call_list, ir_node *pr } /* changes were done ... */ - set_irg_outs_inconsistent(irg); - set_irg_loopinfo_state(irg, loopinfo_cf_inconsistent); - if (exc_changed) { /* ... including exception edges */ - set_irg_doms_inconsistent(irg); + clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE + | IR_GRAPH_STATE_CONSISTENT_LOOPINFO); } } /* fix_nothrow_call_list */ @@ -510,8 +504,23 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int { ir_node *end, *endbl; int j; + ir_entity *entity = get_irg_entity(irg); + ir_type *type = get_entity_type(entity); + size_t n_params = get_method_n_params(type); + size_t i; + mtp_additional_properties may_be_const = mtp_property_const; mtp_additional_properties prop = get_irg_additional_properties(irg); + /* libfirm handles aggregate parameters by passing around pointers to + * stuff in memory, so if we have compound parameters we are never const */ + for (i = 0; i < n_params; ++i) { + ir_type *param = get_method_param_type(type, i); + if (is_compound_type(param)) { + prop &= ~mtp_property_const; + may_be_const = mtp_no_property; + } + } + if (prop & mtp_property_const) { /* already marked as a const function */ return mtp_property_const; @@ -535,7 +544,7 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int end = get_irg_end(irg); endbl = get_nodes_block(end); - prop = mtp_property_const; + prop = may_be_const; ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED); inc_irg_visited(irg); @@ -715,8 +724,8 @@ static int is_stored(const ir_node *n) break; case iro_Call: ptr = get_Call_ptr(succ); - if (is_Global(ptr)) { - ir_entity *ent = get_Global_entity(ptr); + if (is_SymConst_addr_ent(ptr)) { + ir_entity *ent = get_SymConst_entity(ptr); size_t i; /* we know the called entity */ @@ -828,9 +837,9 @@ static mtp_additional_properties check_nothrow_or_malloc(ir_graph *irg, int top) } else if (is_Call(res)) { ir_node *ptr = get_Call_ptr(res); - if (is_Global(ptr)) { + if (is_SymConst_addr_ent(ptr)) { /* a direct call */ - ir_entity *ent = get_Global_entity(ptr); + ir_entity *ent = get_SymConst_entity(ptr); ir_graph *callee = get_entity_irg(ent); if (callee == irg) { @@ -856,7 +865,7 @@ static mtp_additional_properties check_nothrow_or_malloc(ir_graph *irg, int top) for (i = 0; i < n_callees; ++i) { ir_entity *ent = get_Call_callee(res, i); - if (ent == unknown_entity) { + if (is_unknown_entity(ent)) { /* we don't know which entity is called here */ curr_prop &= ~mtp_property_malloc; break; @@ -884,9 +893,9 @@ static mtp_additional_properties check_nothrow_or_malloc(ir_graph *irg, int top) if (is_Call(pred)) { ir_node *ptr = get_Call_ptr(pred); - if (is_Global(ptr)) { + if (is_SymConst_addr_ent(ptr)) { /* a direct call */ - ir_entity *ent = get_Global_entity(ptr); + ir_entity *ent = get_SymConst_entity(ptr); ir_graph *callee = get_entity_irg(ent); if (callee == irg) { @@ -914,7 +923,7 @@ static mtp_additional_properties check_nothrow_or_malloc(ir_graph *irg, int top) for (i = 0; i < n_callees; ++i) { ir_entity *ent = get_Call_callee(pred, i); - if (ent == unknown_entity) { + if (is_unknown_entity(ent)) { /* we don't know which entity is called here */ curr_prop &= ~mtp_property_nothrow; break; @@ -972,7 +981,7 @@ static mtp_additional_properties check_nothrow_or_malloc(ir_graph *irg, int top) static void check_for_possible_endless_loops(ir_graph *irg) { ir_loop *root_loop; - assure_cf_loop(irg); + assure_loopinfo(irg); root_loop = get_irg_loop(irg); if (root_loop->flags & loop_outer_loop)