X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fproc_cloning.c;h=2d359206fa697a8d5871c35cf338682011a38d2a;hb=4cbdab238c1bd78c11cda18f18f8a4ab676e5c56;hp=ab5d99aaa52b684f10fe80390d49d4500abf9c74;hpb=2e179fbd54125606903fc7e438d02a6d3aacc6eb;p=libfirm diff --git a/ir/opt/proc_cloning.c b/ir/opt/proc_cloning.c index ab5d99aaa..2d359206f 100644 --- a/ir/opt/proc_cloning.c +++ b/ir/opt/proc_cloning.c @@ -1,27 +1,12 @@ /* - * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** * @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 +82,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); } /** @@ -268,10 +253,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)); @@ -302,13 +288,12 @@ 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 ((int)pos == get_Proj_proj(proj)) { if (arg) { @@ -515,7 +500,6 @@ static void reorder_weights(q_set *hmap, float threshold) { entry_t **adr, *p, *entry; size_t i, len; - ir_entity *callee; restart: entry = hmap->heavy_uses; @@ -531,9 +515,8 @@ restart: /* we know, that a SymConst is here */ ptr = get_Call_ptr(call); - assert(is_SymConst(ptr)); - callee = get_SymConst_entity(ptr); + ir_entity *const callee = get_SymConst_entity(ptr); if (callee != entry->q.ent) { /* * This call is already changed because of a previous @@ -572,7 +555,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; @@ -586,7 +568,7 @@ restart: */ void proc_cloning(float threshold) { - entry_t *entry = NULL, *p; + entry_t *p; size_t i, n; q_set hmap; @@ -613,7 +595,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); /* @@ -652,14 +634,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;