X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firmemory.c;h=77e71c3d7602e47dac36a5adfe876b7c63088d59;hb=afbbc0b1ccd684c4c24bfd43d0f994123245f39f;hp=f4af23b0f4c7779f2de2e6e0498ee6e66c449578;hpb=d745be6dd7d63b7a2759f4c92b6f449e010bb467;p=libfirm diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index f4af23b0f..77e71c3d7 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -31,6 +31,7 @@ #include #include +#include "adt/pmap.h" #include "irnode_t.h" #include "irgraph_t.h" #include "irprog_t.h" @@ -44,9 +45,11 @@ #include "irprintf.h" #include "debug.h" #include "error.h" +#include "typerep.h" /** The debug handle. */ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) +DEBUG_ONLY(static firm_dbg_module_t *dbgcall = NULL;) /** The source language specific language disambiguator function. */ static DISAMBIGUATOR_FUNC language_disambuigator = NULL; @@ -850,13 +853,36 @@ static ir_entity_usage determine_entity_usage(const ir_node *irn, ir_entity *ent } break; -#if 0 - case iro_Phi: - /* TODO implement marker algo */ -#endif + /* skip identities */ + case iro_Id: + res |= determine_entity_usage(succ, entity); + break; + + /* skip tuples */ + case iro_Tuple: { + int input_nr; + for (input_nr = get_Tuple_n_preds(succ) - 1; input_nr >= 0; + --input_nr) { + ir_node *pred = get_Tuple_pred(succ, input_nr); + if (pred == irn) { + int k; + /* we found one input */ + for (k = get_irn_n_outs(succ) - 1; k >= 0; --k) { + ir_node *proj = get_irn_out(succ, k); + + if (is_Proj(proj) && get_Proj_proj(proj) == input_nr) { + res |= determine_entity_usage(proj, entity); + break; + } + } + } + } + break; + } default: - /* another op, we don't know anything */ + /* another op, we don't know anything (we could do more advanced + * things like a dataflow analysis here) */ res |= ir_usage_unknown; break; } @@ -1138,14 +1164,10 @@ void assure_irp_globals_entity_usage_computed(void) { void firm_init_memory_disambiguator(void) { FIRM_DBG_REGISTER(dbg, "firm.ana.irmemory"); + FIRM_DBG_REGISTER(dbgcall, "firm.opt.cc"); } -#include -#include "typerep.h" - -DEBUG_ONLY(static firm_dbg_module_t *dbgcall = NULL;) - /** Maps method types to cloned method types. */ static pmap *mtp_map; @@ -1202,8 +1224,6 @@ void mark_private_methods(void) { int i; int changed = 0; - FIRM_DBG_REGISTER(dbgcall, "firm.opt.cc"); - assure_irp_globals_entity_usage_computed(); mtp_map = pmap_create();