X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_frame.c;h=191483c1ad33fe7a5aecc85a307bbfb0db5d2765;hb=0ac0b440ce2d239c5e7e7db56b8273559d9a7741;hp=f614f1bdcbccf6c0ae42f2855e11c53bb3e5e48e;hpb=ce6161a7e42a48f7422b7babcc64d8ace18e2687;p=libfirm diff --git a/ir/opt/opt_frame.c b/ir/opt/opt_frame.c index f614f1bdc..191483c1a 100644 --- a/ir/opt/opt_frame.c +++ b/ir/opt/opt_frame.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -22,7 +8,6 @@ * @brief Optimize the frame type. * @date 15.03.2006 * @author Michael Beck - * @version $Id$ * @brief * Optimize the frame type by removing unused type members. */ @@ -44,53 +29,40 @@ void opt_frame_irg(ir_graph *irg) ir_type *frame_tp = get_irg_frame_type(irg); ir_entity *ent, *list; ir_node *frame, *sel; - int i, n = get_class_n_members(frame_tp); + size_t i, n = get_class_n_members(frame_tp); + int o; if (n <= 0) return; - irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK); + assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS); + + irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK); /* clear all entity links */ - for (i = n - 1; i >= 0; --i) { - ent = get_class_member(frame_tp, i); + for (i = n; i > 0;) { + ent = get_class_member(frame_tp, --i); set_entity_link(ent, NULL); } /* look for uses */ frame = get_irg_frame(irg); - if (edges_activated(irg)) { /* use inplace edges */ - const ir_edge_t *edge; - - /* mark all used entities */ - foreach_out_edge(frame, edge) { - sel = get_edge_src_irn(edge); - if (is_Sel(sel)) { - ent = get_Sel_entity(sel); + /* mark all used entities */ + for (o = get_irn_n_outs(frame) - 1; o >= 0; --o) { + sel = get_irn_out(frame, o); + if (is_Sel(sel)) { + ent = get_Sel_entity(sel); + /* only entities on the frame */ + if (get_entity_owner(ent) == frame_tp) set_entity_link(ent, ent); - } - } - } else { - /* use traditionally out edges */ - assure_irg_outs(irg); - - /* mark all used entities */ - for (i = get_irn_n_outs(frame) - 1; i >= 0; --i) { - sel = get_irn_out(frame, i); - if (is_Sel(sel)) { - ent = get_Sel_entity(sel); - /* only entities on the frame */ - if (get_entity_owner(ent) == frame_tp) - set_entity_link(ent, ent); - } } } /* link unused ones */ list = NULL; - for (i = n - 1; i >= 0; --i) { - ent = get_class_member(frame_tp, i); + for (i = n; i > 0;) { + ent = get_class_member(frame_tp, --i); /* beware of inner functions: those are NOT unused */ if (get_entity_link(ent) == NULL && !is_method_entity(ent)) { set_entity_link(ent, list); @@ -104,10 +76,22 @@ void opt_frame_irg(ir_graph *irg) list = (ir_entity*)get_entity_link(ent); free_entity(ent); } - /* we changed the frame type, it's layout should be redefined */ + /* we changed the frame type, its layout should be redefined */ set_type_state(frame_tp, layout_undefined); } - irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK); + irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK); + + /* we changed the type, this affects none of the currently known graph + * properties, but I don't use ALL because I don't know if someone adds + * type-based properties at some point */ + confirm_irg_properties(irg, + IR_GRAPH_PROPERTIES_CONTROL_FLOW + | IR_GRAPH_PROPERTY_NO_BADS + | IR_GRAPH_PROPERTY_NO_TUPLES + | IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES + | IR_GRAPH_PROPERTY_CONSISTENT_OUTS + | IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE + | IR_GRAPH_PROPERTY_MANY_RETURNS); } ir_graph_pass_t *opt_frame_irg_pass(const char *name)