From 6d7f5715979b32673f0d48ef7e69bb63c1eefa97 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 22 Jan 2007 11:01:02 +0000 Subject: [PATCH] - Create new copy_attr functions for blocks, phis and filters that initialize their backedge arrays. - No need to call new_backedge_arr in the DCE anymore - Fix a bug in dce_survivor where it would allocate too few space on the obstack [r8549] --- ir/ir/irgopt.c | 3 +-- ir/ir/irop.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index 27450ba51..0732e9f1b 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -303,7 +303,6 @@ static void copy_node(ir_node *n, void *env) { was allocated on the old obstack the pointers now are dangling. This frees e.g. the memory of the graph_arr allocated in new_immBlock. */ copy_node_attr(n, nn); - new_backedge_info(nn); #ifdef DEBUG_libfirm { @@ -828,7 +827,7 @@ void survive_dce_register_irn(survive_dce_t *sd, ir_node **place) if(*place != NULL) { ir_node *irn = *place; survive_dce_list_t *curr = pmap_get(sd->places, irn); - survive_dce_list_t *nw = obstack_alloc(&sd->obst, sizeof(nw)); + survive_dce_list_t *nw = obstack_alloc(&sd->obst, sizeof(nw[0])); nw->next = curr; nw->place = place; diff --git a/ir/ir/irop.c b/ir/ir/irop.c index 33b2f8d00..59330c6e4 100644 --- a/ir/ir/irop.c +++ b/ir/ir/irop.c @@ -21,6 +21,7 @@ #include "irop_t.h" #include "irnode_t.h" #include "irhooks.h" +#include "irbackedge_t.h" #include "iropt_t.h" /* for firm_set_default_operations */ #include "irvrfy_t.h" @@ -131,10 +132,36 @@ call_copy_attr(const ir_node *old_node, ir_node *new_node) { */ static void block_copy_attr(const ir_node *old_node, ir_node *new_node) { + ir_graph *irg = current_ir_graph; + default_copy_attr(old_node, new_node); + new_node->attr.block.cg_backedge = NULL; + new_node->attr.block.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node)); INIT_LIST_HEAD(&new_node->attr.block.succ_head); } /* block_copy_attr */ +/** + * Copies all phi attributes stored in old node to the new node + */ +static void +phi_copy_attr(const ir_node *old_node, ir_node *new_node) { + ir_graph *irg = current_ir_graph; + + default_copy_attr(old_node, new_node); + new_node->attr.phi_backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node)); +} + +/** + * Copies all filter attributes stored in old node to the new node + */ +static void +filter_copy_attr(const ir_node *old_node, ir_node *new_node) { + ir_graph *irg = current_ir_graph; + + default_copy_attr(old_node, new_node); + new_node->attr.filter.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node)); +} + /** * Sets the default copy_attr operation for an ir_ops * @@ -149,6 +176,10 @@ static ir_op_ops *firm_set_default_copy_attr(ir_opcode code, ir_op_ops *ops) { ops->copy_attr = call_copy_attr; else if (code == iro_Block) ops->copy_attr = block_copy_attr; + else if (code == iro_Phi) + ops->copy_attr = phi_copy_attr; + else if (code == iro_Filter) + ops->copy_attr = filter_copy_attr; else { /* not allowed to be NULL */ if (! ops->copy_attr) -- 2.20.1