X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_frame.c;h=c37621ea3c96dc2a44a0e292c91bd4633630661b;hb=6b124543aff56817fcfe6d5b5ff181ac5c790e73;hp=b9855405750a05a8d7282dc7a2c2b9b0f26444cc;hpb=60292a288c2638c6f6ad2e4fc574943214129a20;p=libfirm diff --git a/ir/opt/opt_frame.c b/ir/opt/opt_frame.c index b98554057..c37621ea3 100644 --- a/ir/opt/opt_frame.c +++ b/ir/opt/opt_frame.c @@ -23,7 +23,7 @@ * @date 15.03.2006 * @author Michael Beck * @version $Id$ - * @summary + * @brief * Optimize the frame type by removing unused type members. */ #include "config.h" @@ -33,6 +33,7 @@ #include "type_t.h" #include "irouts.h" #include "iredges.h" +#include "irpass.h" /* * Optimize the frame type of an irg by removing @@ -78,7 +79,9 @@ void opt_frame_irg(ir_graph *irg) { sel = get_irn_out(frame, i); if (is_Sel(sel)) { ent = get_Sel_entity(sel); - set_entity_link(ent, ent); + /* only entities on the frame */ + if (get_entity_owner(ent) == frame_tp) + set_entity_link(ent, ent); } } } @@ -87,7 +90,8 @@ void opt_frame_irg(ir_graph *irg) { list = NULL; for (i = n - 1; i >= 0; --i) { ent = get_class_member(frame_tp, i); - if (get_entity_link(ent) == NULL) { + /* beware of inner functions: those are NOT unused */ + if (get_entity_link(ent) == NULL && !is_method_entity(ent)) { set_entity_link(ent, list); list = ent; } @@ -104,3 +108,8 @@ void opt_frame_irg(ir_graph *irg) { } irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK); } + +ir_graph_pass_t *opt_frame_irg_pass(const char *name) +{ + return def_graph_pass(name ? name : "opt_frame_irg", opt_frame_irg); +}