X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fcgana.c;h=a1cf2240c9cb44f50c625759f1bcaf71d690e931;hb=bb5c6d5ce2e35c4074900017f8c8e1a4935054d0;hp=d4de5127f5f48a420d9ed584f1f0e84014743040;hpb=8cd28ecf2af21705de8dd175845745270380b4ed;p=libfirm diff --git a/ir/ana/cgana.c b/ir/ana/cgana.c index d4de5127f..a1cf2240c 100644 --- a/ir/ana/cgana.c +++ b/ir/ana/cgana.c @@ -50,6 +50,7 @@ #include "ircons.h" #include "irgmod.h" #include "iropt.h" +#include "irtools.h" #include "irflag_t.h" #include "dbginfo_t.h" @@ -347,7 +348,7 @@ static void free_mark_proj(ir_node * node, long n, eset * set) { * op_Tuple oder ein Knoten, der in "free_ana_walker" behandelt * wird. */ ir_node * pred = get_Proj_pred(node); - if (get_irn_link(pred) != MARK && get_irn_op(pred) == op_Tuple) { + if (get_irn_link(pred) != MARK && is_Tuple(pred)) { free_mark_proj(get_Tuple_pred(pred, get_Proj_proj(node)), n, set); } else { /* nothing: da in "free_ana_walker" behandelt. */ @@ -490,12 +491,15 @@ static void free_ana_walker(ir_node *node, void *env) { * * which is sometimes used to anchor functions. */ -static void add_method_address_intitialzer(ir_initializer_t *initializer, - eset *set) +static void add_method_address_inititializer(ir_initializer_t *initializer, + eset *set) { + ir_node *n; + size_t i; + switch (initializer->kind) { - case IR_INITIALIZER_CONST: { - ir_node *n = initializer->consti.value; + case IR_INITIALIZER_CONST: + n = initializer->consti.value; /* let's check if it's the address of a function */ if (is_Global(n)) { @@ -505,21 +509,17 @@ static void add_method_address_intitialzer(ir_initializer_t *initializer, eset_insert(set, ent); } return; - } case IR_INITIALIZER_TARVAL: case IR_INITIALIZER_NULL: return; - case IR_INITIALIZER_COMPOUND: { - size_t i; - + case IR_INITIALIZER_COMPOUND: for (i = 0; i < initializer->compound.n_initializers; ++i) { ir_initializer_t *sub_initializer = initializer->compound.initializers[i]; - add_method_address_intitialzer(sub_initializer, set); + add_method_address_inititializer(sub_initializer, set); } return; } - } panic("invalid initializer found"); } @@ -545,7 +545,7 @@ static void add_method_address(ir_entity *ent, eset *set) return; if (ent->has_initializer) { - add_method_address_intitialzer(get_entity_initializer(ent), set); + add_method_address_inititializer(get_entity_initializer(ent), set); } else if (is_atomic_entity(ent)) { tp = get_entity_type(ent); @@ -598,20 +598,19 @@ static ir_entity **get_free_methods(int *length) for (i = get_irp_n_irgs() - 1; i >= 0; --i) { irg = get_irp_irg(i); ent = get_irg_entity(irg); - /* insert "external visible" methods. */ if (get_entity_visibility(ent) != visibility_local) { + /* insert non-local (external) methods. */ eset_insert(free_set, ent); - } - /* insert "sticky" methods. */ - if (get_entity_stickyness(ent) == stickyness_sticky) { + } else if (get_entity_stickyness(ent) == stickyness_sticky) { + /* insert "sticky" methods. */ eset_insert(free_set, ent); } - set_using_irn_link(irg); - /* Find all method entities that gets "visible" trough this graphs, + ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK); + /* Find all method entities that gets "visible" through this graphs, * for instance because their address is stored. */ - irg_walk_graph(irg, NULL, free_ana_walker, free_set); - clear_using_irn_link(irg); + irg_walk_graph(irg, firm_clear_link, free_ana_walker, free_set); + ir_free_resources(irg, IR_RESOURCE_IRN_LINK); } /* insert all methods that are used in global variables initializers */ @@ -633,7 +632,7 @@ static ir_entity **get_free_methods(int *length) /* Finally, transform the set into an array. */ *length = eset_count(free_set); - arr = xmalloc(sizeof(ir_entity *) * (*length)); + arr = XMALLOCN(ir_entity*, *length); for (i = 0, ent = eset_first(free_set); ent; ent = eset_next(free_set)) { arr[i++] = ent; } @@ -743,13 +742,6 @@ static void callee_ana_node(ir_node *node, eset *methods) { callee_ana_node(get_Mux_true(node), methods); break; - case iro_Psi: - for (i = get_Psi_n_conds(node) - 1; i >= 0; --i) { - callee_ana_node(get_Psi_val(node, i), methods); - } - callee_ana_node(get_Psi_default(node), methods); - break; - case iro_Id: callee_ana_node(get_Id_pred(node), methods); break;