-/* Defined in iropt.c */
-void del_identities (pset *value_table);
-
-/* Frees the passed irgraph.
- Deallocates all nodes in this graph and the ir_graph structure.
- Sets the field irgraph in the corresponding entity to NULL.
- Does not remove the irgraph from the list in irprog (requires
- inefficient search, call remove_irp_irg by hand).
- Does not free types, entities or modes that are used only by this
- graph, nor the entity standing for this graph. */
-void free_ir_graph (ir_graph *irg) {
- assert(is_ir_graph(irg));
-
- hook_free_graph(irg);
- if (irg->outs_state != outs_none) free_irg_outs(irg);
- if (irg->frame_type) free_type(irg->frame_type);
- if (irg->value_table) del_identities(irg->value_table);
- if (irg->ent) {
- ir_peculiarity pec = get_entity_peculiarity (irg->ent);
- set_entity_peculiarity (irg->ent, peculiarity_description);
- set_entity_irg(irg->ent, NULL); /* not set in const code irg */
- set_entity_peculiarity (irg->ent, pec);
+/**
+ * Pre-Walker: Copies blocks and nodes from the original method graph
+ * to the copied graph.
+ *
+ * @param n A node from the original method graph.
+ * @param env The copied graph.
+ */
+static void copy_all_nodes(ir_node *node, void *env)
+{
+ ir_graph *irg = (ir_graph*)env;
+ ir_node *new_node = irn_copy_into_irg(node, irg);
+
+ set_irn_link(node, new_node);
+
+ /* fix access to entities on the stack frame */
+ if (is_Sel(new_node)) {
+ ir_entity *ent = get_Sel_entity(new_node);
+ ir_type *tp = get_entity_owner(ent);
+
+ if (is_frame_type(tp)) {
+ /* replace by the copied entity */
+ ent = (ir_entity*)get_entity_link(ent);
+
+ assert(is_entity(ent));
+ assert(get_entity_owner(ent) == get_irg_frame_type(irg));
+ set_Sel_entity(new_node, ent);
+ }