X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fheight.c;h=482268f28a93fb1a5df278917769f789d2ebe531;hb=45ecc187cee7107c83c1f9618a1e1e586df73644;hp=2b35665c3e45b1419ce2372a2946f9666527fa6a;hpb=974215da1a935f250766874d0f7a7ddfa34bc4ef;p=libfirm diff --git a/ir/ana/height.c b/ir/ana/height.c index 2b35665c3..482268f28 100644 --- a/ir/ana/height.c +++ b/ir/ana/height.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. * @@ -52,9 +52,10 @@ typedef struct { unsigned visited; } irn_height_t; -static void *irn_height_init(ir_phase *ph, ir_node *irn, void *data) +static void *irn_height_init(ir_phase *ph, const ir_node *irn, void *data) { irn_height_t *h = data ? data : phase_alloc(ph, sizeof(h[0])); + (void)irn; memset(h, 0, sizeof(h[0])); return h; } @@ -85,9 +86,11 @@ static int search(heights_t *h, const ir_node *curr, const ir_node *tgt) if(curr == tgt) return 1; - /* If we are in another block we won't find our target. */ + /* If we are in another block or at a phi we won't find our target. */ if(get_nodes_block(curr) != get_nodes_block(tgt)) return 0; + if(is_Phi(curr)) + return 0; /* Check, if we have already been here. Coming more often won't help :-) */ h_curr = phase_get_irn_data(&h->ph, curr); @@ -154,7 +157,7 @@ static unsigned compute_height(heights_t *h, ir_node *irn, const ir_node *bl) foreach_out_edge(irn, edge) { ir_node *dep = get_edge_src_irn(edge); - if(!is_Block(dep) && get_nodes_block(dep) == bl) { + if(!is_Block(dep) && !is_Phi(dep) && get_nodes_block(dep) == bl) { unsigned dep_height = compute_height(h, dep, bl); ih->height = MAX(ih->height, dep_height); } @@ -165,6 +168,7 @@ static unsigned compute_height(heights_t *h, ir_node *irn, const ir_node *bl) foreach_out_edge_kind(irn, edge, EDGE_KIND_DEP) { ir_node *dep = get_edge_src_irn(edge); + assert(!is_Phi(dep)); if(!is_Block(dep) && get_nodes_block(dep) == bl) { unsigned dep_height = compute_height(h, dep, bl); ih->height = MAX(ih->height, dep_height); @@ -241,7 +245,7 @@ void heights_recompute(heights_t *h) heights_t *heights_new(ir_graph *irg) { - heights_t *res = xmalloc(sizeof(res[0])); + heights_t *res = XMALLOC(heights_t); phase_init(&res->ph, "heights", irg, PHASE_DEFAULT_GROWTH, irn_height_init, NULL); res->dump_handle = dump_add_node_info_callback(height_dump_cb, res); heights_recompute(res);