+/**
+ * Creates a deep copy of an entity.
+ */
+static ir_entity *deep_entity_copy(ir_entity *old)
+{
+ ir_entity *newe = XMALLOC(ir_entity);
+
+ *newe = *old;
+ if (is_compound_entity(old)) {
+ if (old->has_initializer) {
+ /* FIXME: the initializers are NOT copied */
+ } else {
+ newe->attr.cmpd_attr.values = NULL;
+ newe->attr.cmpd_attr.val_paths = NULL;
+ if (old->attr.cmpd_attr.values)
+ newe->attr.cmpd_attr.values = DUP_ARR_F(ir_node *, old->attr.cmpd_attr.values);
+
+ /* FIXME: the compound graph paths are NOT copied */
+ if (old->attr.cmpd_attr.val_paths)
+ newe->attr.cmpd_attr.val_paths = DUP_ARR_F(compound_graph_path *, old->attr.cmpd_attr.val_paths);
+ }
+ } else if (is_method_entity(old)) {
+ /* do NOT copy them, reanalyze. This might be the best solution */
+ newe->attr.mtd_attr.param_access = NULL;
+ newe->attr.mtd_attr.param_weight = NULL;
+ }
+
+#ifdef DEBUG_libfirm
+ newe->nr = get_irp_new_node_nr();
+#endif
+ return newe;
+}