X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_polymorphy.c;h=48e8ac8bf3a9055635cbae4d98b8011bf64aa2af;hb=98c8808ee1d34300860bb78185558e1731a99368;hp=3e3ada34d46d92040b830dd00f0c1fe48eea59d7;hpb=8eb0a1256d88d68e762c1f087bffadca68dc5c12;p=libfirm diff --git a/ir/opt/opt_polymorphy.c b/ir/opt/opt_polymorphy.c index 3e3ada34d..48e8ac8bf 100644 --- a/ir/opt/opt_polymorphy.c +++ b/ir/opt/opt_polymorphy.c @@ -5,7 +5,7 @@ * Author: * Created: * CVS-ID: $Id$ - * Copyright: (c) 2005 Universität Karlsruhe + * Copyright: (c) 2005 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ @@ -41,8 +41,9 @@ static type *get_dynamic_type(ir_node *ptr) { */ ir_node *transform_node_Sel(ir_node *node) { - entity *ent = get_Sel_entity(node); - ir_node *new_node; + ir_node *new_node, *ptr; + type *dyn_tp; + entity *ent = get_Sel_entity(node); if (get_irp_phase_state() == phase_building) return node; @@ -54,7 +55,7 @@ ir_node *transform_node_Sel(ir_node *node) /* If the entity is a leave in the inheritance tree, we can replace the Sel by a constant. */ - if ((get_irp_phase_state() != phase_building) && (get_entity_n_overwrittenby(ent) == 0)) { + if (get_entity_n_overwrittenby(ent) == 0) { /* In dead code, we might call a leave entity that is a description. Do not turn the Sel to a SymConst. */ if (get_entity_peculiarity(ent) == peculiarity_description) { @@ -72,18 +73,19 @@ ir_node *transform_node_Sel(ir_node *node) } /* If we know the dynamic type, we can replace the Sel by a constant. */ - ir_node *ptr = get_Sel_ptr(node); /* The address we select from. */ - type *dyn_tp = get_dynamic_type(ptr); /* The runtime type of ptr. */ + ptr = get_Sel_ptr(node); /* The address we select from. */ + dyn_tp = get_dynamic_type(ptr); /* The runtime type of ptr. */ if (dyn_tp != firm_unknown_type) { entity *called_ent; + ir_node *rem_block; /* We know which method will be called, no dispatch necessary. */ called_ent = resolve_ent_polymorphy(dyn_tp, ent); /* called_ent may not be description: has no Address/Const to Call! */ assert(get_entity_peculiarity(called_ent) != peculiarity_description); - ir_node *rem_block = get_cur_block(); + rem_block = get_cur_block(); set_cur_block(get_nodes_block(node)); new_node = copy_const_value(get_atomic_ent_value(called_ent)); set_cur_block(rem_block); @@ -101,20 +103,22 @@ ir_node *transform_node_Sel(ir_node *node) * This function returns a node replacing the Proj(Load)[Value]. * If this is actually called in transform_node, we must build * a tuple, or replace the Projs of the load. - * Therefore we call this optimization in ldstopt. + * Therefore we call this optimization in ldstopt(). */ ir_node *transform_node_Load(ir_node *n) { + ir_node *field_ptr, *new_node, *ptr; + entity *ent; + type *dyn_tp; + if (!(get_opt_optimize() && get_opt_dyn_meth_dispatch())) return n; - ir_node *field_ptr = get_Load_ptr(n); + field_ptr = get_Load_ptr(n); if (get_irn_op(field_ptr) != op_Sel) return n; - entity *ent = get_Sel_entity(field_ptr); - ir_node *new_node; - + ent = get_Sel_entity(field_ptr); if ((get_entity_allocation(ent) != allocation_static) || (get_entity_variability(ent) != variability_constant) ) return n; @@ -129,8 +133,8 @@ ir_node *transform_node_Load(ir_node *n) } /* If we know the dynamic type, we can replace the Sel by a constant. */ - ir_node *ptr = get_Sel_ptr(field_ptr); /* The address we select from. */ - type *dyn_tp = get_dynamic_type(ptr); /* The runtime type of ptr. */ + ptr = get_Sel_ptr(field_ptr); /* The address we select from. */ + dyn_tp = get_dynamic_type(ptr); /* The runtime type of ptr. */ if (dyn_tp != firm_unknown_type) { entity *loaded_ent;