X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fproc_cloning.c;h=d61b23375b178548ccbffa2617a9db870b943956;hb=12aaa3fc53618991634823a6738f50360a54633b;hp=119ba7081770b7fd273d822e5302f4444f40989f;hpb=a88bcf9f8b48eefb74e3011f6ac6bfcd468183e5;p=libfirm diff --git a/ir/opt/proc_cloning.c b/ir/opt/proc_cloning.c index 119ba7081..d61b23375 100644 --- a/ir/opt/proc_cloning.c +++ b/ir/opt/proc_cloning.c @@ -21,7 +21,6 @@ * @file * @brief Procedure cloning. * @author Beyhan Veliev, Michael Beck - * @version $Id$ * @brief * * The purpose is first to find and analyze functions, that are called @@ -97,7 +96,7 @@ static int entry_cmp(const void *elt, const void *key) */ static unsigned hash_entry(const entry_t *entry) { - return HASH_PTR(entry->q.ent) ^ HASH_PTR(entry->q.tv) ^ (unsigned)(entry->q.pos * 9); + return hash_ptr(entry->q.ent) ^ hash_ptr(entry->q.tv) ^ (unsigned)(entry->q.pos * 9); } /** @@ -120,18 +119,17 @@ static void kill_entry(entry_t *entry) */ static void process_call(ir_node *call, ir_entity *callee, q_set *hmap) { - ir_type *mtp; entry_t *key, *entry; ir_node *call_param; size_t i, n_params; n_params = get_Call_n_params(call); - /* Beware: we cannot clone variadic parameters as well as the + /* TODO + * Beware: we cannot clone variadic parameters as well as the * last non-variadic one, which might be needed for the va_start() * magic */ - mtp = get_Call_type(call); /* In this for loop we collect the calls, that have an constant parameter. */ @@ -184,10 +182,10 @@ static void collect_irg_calls(ir_node *call, void *env) if (is_Call(call)) { call_ptr = get_Call_ptr(call); - if (! is_Global(call_ptr)) + if (! is_SymConst_addr_ent(call_ptr)) return; - callee = get_Global_entity(call_ptr); + callee = get_SymConst_entity(call_ptr); /* we don't know which function gets finally bound to a weak symbol */ if (get_entity_linkage(callee) & IR_LINKAGE_WEAK) @@ -269,10 +267,11 @@ static void set_preds(ir_node *irn, void *env) irn_copy = (ir_node*)get_irn_link(irn); if (is_Block(irn)) { + ir_graph *const irg = get_Block_irg(irn); for (i = get_Block_n_cfgpreds(irn) - 1; i >= 0; --i) { pred = get_Block_cfgpred(irn, i); /* "End" block must be handled extra, because it is not matured.*/ - if (get_irg_end_block(current_ir_graph) == irn) + if (get_irg_end_block(irg) == irn) add_immBlock_pred(get_irg_end_block(clone_irg), (ir_node*)get_irn_link(pred)); else set_Block_cfgpred(irn_copy, i, (ir_node*)get_irn_link(pred)); @@ -303,15 +302,14 @@ static void set_preds(ir_node *irn, void *env) static ir_node *get_irg_arg(ir_graph *irg, size_t pos) { ir_node *irg_args = get_irg_args(irg), *arg = NULL; - int i; /* Call algorithm that computes the out edges */ assure_irg_outs(irg); /* Search the argument with the number pos.*/ - for (i = get_irn_n_outs(irg_args) - 1; i >= 0; --i) { + for (unsigned i = get_irn_n_outs(irg_args); i-- > 0; ) { ir_node *proj = get_irn_out(irg_args, i); - if (pos == get_Proj_proj(proj)) { + if ((int)pos == get_Proj_proj(proj)) { if (arg) { /* * More than one arg node found: @@ -412,7 +410,6 @@ static ir_entity *clone_method(const quadruple_t *q) { ir_entity *new_entity; ident *clone_ident; - symconst_symbol sym; /* A counter for the clones.*/ static size_t nr = 0; @@ -433,9 +430,6 @@ static ir_entity *clone_method(const quadruple_t *q) /* We need now a new ir_graph for our clone method. */ create_clone_proc_irg(new_entity, q); - /* We must set the atomic value of our "new_entity". */ - sym.entity_p = new_entity; - /* The "new_entity" don't have this information. */ new_entity->attr.mtd_attr.param_access = NULL; new_entity->attr.mtd_attr.param_weight = NULL; @@ -577,7 +571,6 @@ restart: hmap->heavy_uses = entry->next; entry->next = *adr; *adr = entry; - entry = hmap->heavy_uses; /* we have changed the list, check the next one */ goto restart; @@ -591,7 +584,7 @@ restart: */ void proc_cloning(float threshold) { - entry_t *entry = NULL, *p; + entry_t *p; size_t i, n; q_set hmap; @@ -618,7 +611,7 @@ void proc_cloning(float threshold) /* We iterate the set and arrange the element of the set in a list. The elements are arranged dependent of their value descending.*/ if (hmap.map) { - foreach_pset(hmap.map, entry_t*, entry) { + foreach_pset(hmap.map, entry_t, entry) { entry->weight = calculate_weight(entry); /* @@ -657,14 +650,14 @@ void proc_cloning(float threshold) #ifdef DEBUG_libfirm /* Print some information about the list. */ DB((dbg, LEVEL_2, "-----------------\n")); - for (entry = hmap.heavy_uses; entry; entry = entry->next) { + for (entry_t *entry = hmap.heavy_uses; entry; entry = entry->next) { DB((dbg, LEVEL_2, "\nweight: is %f\n", entry->weight)); DB((dbg, LEVEL_2, "Call for Method %E\n", entry->q.ent)); DB((dbg, LEVEL_2, "Position %zu\n", entry->q.pos)); DB((dbg, LEVEL_2, "Value %T\n", entry->q.tv)); } #endif - entry = hmap.heavy_uses; + entry_t *const entry = hmap.heavy_uses; if (entry) { quadruple_t *qp = &entry->q;