- Create new copy_attr functions for blocks, phis and filters that initialize
authorMatthias Braun <matze@braunis.de>
Mon, 22 Jan 2007 11:01:02 +0000 (11:01 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 22 Jan 2007 11:01:02 +0000 (11:01 +0000)
  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
ir/ir/irop.c

index 27450ba..0732e9f 100644 (file)
@@ -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;
index 33b2f8d..59330c6 100644 (file)
@@ -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)