X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fdata_flow_scalar_replace.c;h=2b535e42c871a7392d249fbe657a06da4f5e2b45;hb=1268a295e95b532b46e2aed04505d5206181afda;hp=8d3f0882acae97fc3500bfab4b3a93437a50a154;hpb=4b1138a9eee25ce11adbb7d7162eaa49421e8b51;p=libfirm diff --git a/ir/opt/data_flow_scalar_replace.c b/ir/opt/data_flow_scalar_replace.c index 8d3f0882a..2b535e42c 100644 --- a/ir/opt/data_flow_scalar_replace.c +++ b/ir/opt/data_flow_scalar_replace.c @@ -23,9 +23,7 @@ * @author Beyhan Veliev, Michael Beck * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include "iroptimize.h" @@ -310,7 +308,7 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel) * visited more than once causing a ring here, so we use the * node flag to mark linked nodes */ - if (irn_visited(sel)) + if (irn_visited_else_mark(sel)) return; /* @@ -318,8 +316,6 @@ static void link_all_leave_sels(ir_entity *ent, ir_node *sel) */ set_irn_link(sel, get_entity_link(ent)); set_entity_link(ent, sel); - - mark_irn_visited(sel); } /* we need a special address that serves as an address taken marker */ @@ -343,6 +339,7 @@ static void *ADDRESS_TAKEN = &_x; static int find_possible_replacements(ir_graph *irg) { ir_node *irg_frame = get_irg_frame(irg); + ir_type *frame_tp; int i, n; int res = 0; @@ -351,19 +348,12 @@ static int find_possible_replacements(ir_graph *irg) n = get_irn_n_outs(irg_frame); /* - * First, clear the link field of all interestingentities. - * Note that we did not rely on the fact that there is only - * one Sel node per entity, so we might access one entity - * more than once here. - * That's why we have need two loops. + * First, clear the link field of all interesting entities. */ - for (i = 0; i < n; ++i) { - ir_node *succ = get_irn_out(irg_frame, i); - - if (is_Sel(succ)) { - ir_entity *ent = get_Sel_entity(succ); - set_entity_link(ent, NULL); - } + frame_tp = get_irg_frame_type(irg); + for (i = get_class_n_members(frame_tp) - 1; i >= 0; --i) { + ir_entity *ent = get_class_member(frame_tp, i); + set_entity_link(ent, NULL); } /* @@ -378,7 +368,12 @@ static int find_possible_replacements(ir_graph *irg) ir_entity *ent = get_Sel_entity(succ); ir_type *ent_type; - if (get_entity_link(ent) == ADDRESS_TAKEN) + /* we are only interested in entities on the frame, NOT + on the value type */ + if (get_entity_owner(ent) != frame_tp) + continue; + + if (get_entity_link(ent) == ADDRESS_TAKEN) continue; /* @@ -445,8 +440,7 @@ static path_t *find_path(ir_node *sel, unsigned len) if (!is_Sel(pred)) { /* we found the root */ - - res = xmalloc(sizeof(*res) + (len - 1) * sizeof(res->path)); + res = XMALLOCF(path_t, path, len); res->path_len = len; } else @@ -762,9 +756,8 @@ static void split_phi_mem_edge(ir_node *irn, env_t *env) { irn_blk = get_nodes_block(irn); val_arr = get_irn_link(irn_blk); - n = get_Block_n_cfgpreds(irn_blk); - - in = alloca(sizeof(*in) * n); + n = get_Block_n_cfgpreds(irn_blk); + in = ALLOCAN(ir_node*, n); for(value_ent = set_first(env->set_ent); value_ent; value_ent = set_next(env->set_ent)) if(val_arr[GET_ENT_VNUM(value_ent->ent)].access_type < 3) @@ -1144,7 +1137,7 @@ static void sync_mem_edges(env_t *env) { vnum_state++; /* We allocate the memory, that we need for the predecessors of the sync.*/ - in = xmalloc(sizeof(ir_node*) *vnum_state); + in = XMALLOCN(ir_node*, vnum_state); /* The global memory edge is the first predecessor of this sync node.*/ if(val_arr[env->gl_mem_vnum].mem_edge_state == NULL) {