X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fescape_ana.c;h=9b5010bf7eda4577ad465bef41eb0c26d6aa0e1a;hb=3398ae4a8b3cbf66cb0b274ddcd85a2ea863ece1;hp=92a6d72b9b08a3390efbdb2c41f57b73a8750c59;hpb=0fbcef83aa6060534172bb13e71cdadb04428806;p=libfirm diff --git a/ir/opt/escape_ana.c b/ir/opt/escape_ana.c index 92a6d72b9..9b5010bf7 100644 --- a/ir/opt/escape_ana.c +++ b/ir/opt/escape_ana.c @@ -47,11 +47,12 @@ #include "ircons.h" #include "irprintf.h" #include "debug.h" +#include "error.h" /** * walker environment */ -typedef struct _walk_env { +typedef struct walk_env { ir_node *found_allocs; /**< list of all found non-escaped allocs */ ir_node *dead_allocs; /**< list of all found dead alloc */ check_alloc_entity_func callback; /**< callback that checks a given entity for allocation */ @@ -61,7 +62,7 @@ typedef struct _walk_env { /* these fields are only used in the global escape analysis */ ir_graph *irg; /**< the irg for this environment */ - struct _walk_env *next; /**< for linking environments */ + struct walk_env *next; /**< for linking environments */ } walk_env_t; @@ -91,16 +92,14 @@ static int is_method_leaving_raise(ir_node *raise) /* Hmm: no ProjX from a Raise? This should be a verification * error. For now we just assert and return. */ - assert(! "No ProjX after Raise found"); - return 1; + panic("No ProjX after Raise found"); } if (get_irn_n_outs(proj) != 1) { /* Hmm: more than one user of ProjX: This is a verification * error. */ - assert(! "More than one user of ProjX"); - return 1; + panic("More than one user of ProjX"); } n = get_irn_out(proj, 0); @@ -117,7 +116,8 @@ static int is_method_leaving_raise(ir_node *raise) * returns an Alloc node if the node adr Select * from one */ -static ir_node *is_depend_alloc(ir_node *adr) { +static ir_node *is_depend_alloc(ir_node *adr) +{ ir_node *alloc; if (!is_Sel(adr)) @@ -141,7 +141,8 @@ static ir_node *is_depend_alloc(ir_node *adr) { * determine if a value calculated by n "escape", ie * is stored somewhere we could not track */ -static int can_escape(ir_node *n) { +static int can_escape(ir_node *n) +{ int i, j, k; /* should always be pointer mode or we made some mistake */ @@ -277,9 +278,9 @@ static int can_escape(ir_node *n) { */ static void find_allocations(ir_node *alloc, void *ctx) { + walk_env_t *env = (walk_env_t*)ctx; int i; ir_node *adr; - walk_env_t *env = ctx; if (! is_Alloc(alloc)) return; @@ -320,10 +321,10 @@ static void find_allocations(ir_node *alloc, void *ctx) */ static void find_allocation_calls(ir_node *call, void *ctx) { + walk_env_t *env = (walk_env_t*)ctx; int i; ir_node *adr; ir_entity *ent; - walk_env_t *env = ctx; if (! is_Call(call)) return; @@ -384,7 +385,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) /* kill all dead allocs */ for (alloc = env->dead_allocs; alloc; alloc = next) { - next = get_irn_link(alloc); + next = (ir_node*)get_irn_link(alloc); DBG((dbgHandle, LEVEL_1, "%+F allocation of %+F unused, deleted.\n", irg, alloc)); @@ -392,7 +393,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) blk = get_nodes_block(alloc); turn_into_tuple(alloc, pn_Alloc_max); set_Tuple_pred(alloc, pn_Alloc_M, mem); - set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(irg, blk)); + set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk)); set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg)); ++env->nr_deads; @@ -401,8 +402,8 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) /* convert all non-escaped heap allocs into frame variables */ ftp = get_irg_frame_type(irg); for (alloc = env->found_allocs; alloc; alloc = next) { - next = get_irn_link(alloc); - size = get_Alloc_size(alloc); + next = (ir_node*)get_irn_link(alloc); + size = get_Alloc_count(alloc); atp = get_Alloc_type(alloc); tp = NULL; @@ -410,9 +411,8 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) /* if the size is a type size and the types matched */ assert(atp == get_SymConst_type(size)); tp = atp; - } - else if (is_Const(size)) { - tarval *tv = get_Const_tarval(size); + } else if (is_Const(size)) { + ir_tarval *tv = get_Const_tarval(size); if (tv != tarval_bad && tarval_is_long(tv) && get_type_state(atp) == layout_fixed && @@ -433,13 +433,12 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) name[sizeof(name) - 1] = '\0'; ent = new_d_entity(ftp, new_id_from_str(name), get_Alloc_type(alloc), dbg); - sel = new_rd_simpleSel(dbg, irg, get_nodes_block(alloc), - get_irg_no_mem(irg), get_irg_frame(irg), ent); + sel = new_rd_simpleSel(dbg, get_nodes_block(alloc), get_irg_no_mem(irg), get_irg_frame(irg), ent); mem = get_Alloc_mem(alloc); turn_into_tuple(alloc, pn_Alloc_max); set_Tuple_pred(alloc, pn_Alloc_M, mem); - set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(irg, blk)); + set_Tuple_pred(alloc, pn_Alloc_X_regular, new_r_Jmp(blk)); set_Tuple_pred(alloc, pn_Alloc_X_except, new_r_Bad(irg)); set_Tuple_pred(alloc, pn_Alloc_res, sel); @@ -479,18 +478,17 @@ static void transform_alloc_calls(ir_graph *irg, walk_env_t *env) /* kill all dead allocs */ for (call = env->dead_allocs; call; call = next) { - next = get_irn_link(call); + next = (ir_node*)get_irn_link(call); DBG((dbgHandle, LEVEL_1, "%+F allocation of %+F unused, deleted.\n", irg, call)); mem = get_Call_mem(call); blk = get_nodes_block(call); turn_into_tuple(call, pn_Call_max); - set_Tuple_pred(call, pn_Call_M_regular, mem); - set_Tuple_pred(call, pn_Call_X_regular, new_r_Jmp(irg, blk)); - set_Tuple_pred(call, pn_Call_X_except, new_r_Bad(irg)); - set_Tuple_pred(call, pn_Call_T_result, new_r_Bad(irg)); - set_Tuple_pred(call, pn_Call_M_except, mem); + set_Tuple_pred(call, pn_Call_M, mem); + set_Tuple_pred(call, pn_Call_X_regular, new_r_Jmp(blk)); + set_Tuple_pred(call, pn_Call_X_except, new_r_Bad(irg)); + set_Tuple_pred(call, pn_Call_T_result, new_r_Bad(irg)); set_Tuple_pred(call, pn_Call_P_value_res_base, new_r_Bad(irg)); ++env->nr_deads; @@ -499,7 +497,7 @@ static void transform_alloc_calls(ir_graph *irg, walk_env_t *env) /* convert all non-escaped heap allocs into frame variables */ ftp = get_irg_frame_type(irg); for (call = env->found_allocs; call; call = next) { - next = get_irn_link(call); + next = (ir_node*)get_irn_link(call); } } @@ -561,7 +559,7 @@ void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback) obstack_init(&obst); elist = NULL; - env = obstack_alloc(&obst, sizeof(*env)); + env = OALLOC(&obst, walk_env_t); env->found_allocs = NULL; env->dead_allocs = NULL; env->callback = callback; @@ -587,7 +585,7 @@ void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback) elist = env; - env = obstack_alloc(&obst, sizeof(*env)); + env = OALLOC(&obst, walk_env_t); env->found_allocs = NULL; env->dead_allocs = NULL; env->callback = callback;