X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fescape_ana.c;h=ea0f4e00b400fa7c869f61e759a9ca548cd095bc;hb=df8a7c32fa1de6a6c64b69f01e2748efb7ce1c11;hp=f486ed4cee74e94478ddfd52dfabc0df66c7b152;hpb=4ebc4b6497324aa5d2380a897c75d3c391760ba0;p=libfirm diff --git a/ir/opt/escape_ana.c b/ir/opt/escape_ana.c index f486ed4ce..ea0f4e00b 100644 --- a/ir/opt/escape_ana.c +++ b/ir/opt/escape_ana.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -47,6 +47,7 @@ #include "analyze_irg_args.h" #include "irgmod.h" #include "ircons.h" +#include "irprintf.h" #include "debug.h" /** @@ -114,6 +115,30 @@ static int is_method_leaving_raise(ir_node *raise) return 0; } +/** + * returns an Alloc node if the node adr Select + * from one + */ +static ir_node *is_depend_alloc(ir_node *adr) { + ir_node *alloc; + + if (!is_Sel(adr)) + return NULL; + + /* should be a simple Sel */ + if (get_Sel_n_indexs(adr) != 0) + return NULL; + + alloc = skip_Proj(get_Sel_ptr(adr)); + if (!is_Alloc(alloc)) + return NULL; + + /* hmm, we depend on this Alloc */ + ir_printf("depend alloc %+F\n", alloc); + + return NULL; +} + /** * determine if a value calculated by n "escape", ie * is stored somewhere we could not track @@ -130,6 +155,15 @@ static int can_escape(ir_node *n) { switch (get_irn_opcode(succ)) { case iro_Store: if (get_Store_value(succ) == n) { + ir_node *adr = get_Store_ptr(succ); + + /* + * if this Alloc depends on another one, + * we can enqueue it + */ + if (is_depend_alloc(adr)) + break; + /* * We are storing n. As long as we do not further * evaluate things, the pointer 'escape' here @@ -149,8 +183,7 @@ static int can_escape(ir_node *n) { ir_node *ptr = get_Call_ptr(succ); ir_entity *ent; - if (get_irn_op(ptr) == op_SymConst && - get_SymConst_kind(ptr) == symconst_addr_ent) { + if (is_SymConst_addr_ent(ptr)) { ent = get_SymConst_entity(ptr); /* we know the called entity */ @@ -163,7 +196,7 @@ static int can_escape(ir_node *n) { } } } - else if (get_irn_op(ptr) == op_Sel) { + else if (is_Sel(ptr)) { /* go through all possible callees */ for (k = get_Call_n_callees(succ) - 1; k >= 0; --k) { ent = get_Call_callee(succ, k); @@ -297,7 +330,7 @@ static void find_allocation_calls(ir_node *call, void *ctx) if (! is_Call(call)) return; adr = get_Call_ptr(call); - if (! is_SymConst(adr) || get_SymConst_kind(adr) != symconst_addr_ent) + if (! is_SymConst_addr_ent(adr)) return; ent = get_SymConst_entity(adr); if (! env->callback(ent)) @@ -399,6 +432,7 @@ static void transform_allocs(ir_graph *irg, walk_env_t *env) DBG((dbgHandle, LEVEL_DEFAULT, "%+F allocation of %+F type %+F placed on frame\n", irg, alloc, tp)); snprintf(name, sizeof(name), "%s_NE_%u", get_entity_name(get_irg_entity(irg)), nr++); + 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),