} else {
/* Allocate new array, don't free old in_array, it's on the obstack. */
ir_node *block = get_nodes_block(node);
- node->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, arity+1);
- edges_invalidate(node, current_ir_graph);
+ edges_invalidate(node, current_ir_graph);
+ node->in = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity+1);
+ /* clear the new in array, else edge_notify tries to delete garbage */
+ memset(node->in, 0, (arity+1) * sizeof(node->in[0]));
set_nodes_block(node, block);
}
}
void
exchange (ir_node *old, ir_node *nw)
{
- /*
- * If new outs are on, we can skip the id node creation and reroute
- * the edges from the old node to the new directly.
- */
- if (edges_activated(current_ir_graph)) {
- edges_reroute(old, nw, current_ir_graph);
- }
+ hook_replace(old, nw);
+
+ /*
+ * If new outs are on, we can skip the id node creation and reroute
+ * the edges from the old node to the new directly.
+ */
+ if (edges_activated(current_ir_graph)) {
+ edges_reroute(old, nw, current_ir_graph);
+ }
else {
/* Else, do it the old-fashioned way. */
- ir_graph *irg = get_irn_irg (old);
- ir_node *block;
+ ir_graph *irg = get_irn_irg (old);
+ ir_node *block;
- assert(old != nw);
- assert (irg);
- assert(get_irn_op(old)->opar != oparity_dynamic);
+ assert(old != nw);
+ assert (irg);
+ assert(get_irn_op(old)->opar != oparity_dynamic);
- hook_turn_into_id(old);
+ hook_turn_into_id(old);
- block = old->in[0];
- if (!block) {
- block = is_Block(nw) ? nw : get_nodes_block(nw);
+ block = old->in[0];
+ if (!block) {
+ block = is_Block(nw) ? nw : get_nodes_block(nw);
- if (!block) {
- DDMN(old);
- DDMN(nw);
- assert(0 && "cannot find legal block for id");
- }
- }
+ if (!block) {
+ DDMN(old);
+ DDMN(nw);
+ assert(0 && "cannot find legal block for id");
+ }
+ }
- old->op = op_Id;
- old->in = NEW_ARR_D (ir_node *, irg->obst, 2);
- old->in[0] = block;
- old->in[1] = nw;
- }
+ old->op = op_Id;
+ old->in = NEW_ARR_D (ir_node *, irg->obst, 2);
+ old->in[0] = block;
+ old->in[1] = nw;
+ }
}
/*--------------------------------------------------------------------*/
get_Block_cfgpred_arr(old_block));
set_irg_current_block(current_ir_graph, new_block);
{
- ir_node *in[1];
- in[0] = new_Jmp();
- set_irn_in(old_block, 1, in);
+ ir_node *jmp = new_Jmp();
+ set_irn_in(old_block, 1, &jmp);
irn_vrfy_irg(old_block, current_ir_graph);
}