From 96cf55be5ccfeefd2dee0648eec8493888618c52 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 6 Sep 2011 17:01:41 +0200 Subject: [PATCH] functions with compound parameters are never const in firm This should fix fehler200.c --- ir/opt/funccall.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index 256e32c07..ef5c90139 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -508,8 +508,23 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int { ir_node *end, *endbl; int j; + ir_entity *entity = get_irg_entity(irg); + ir_type *type = get_entity_type(entity); + size_t n_params = get_method_n_params(type); + size_t i; + mtp_additional_properties may_be_const = mtp_property_const; mtp_additional_properties prop = get_irg_additional_properties(irg); + /* libfirm handles aggregate parameters by passing around pointers to + * stuff in memory, so if we have compound parameters we are never const */ + for (i = 0; i < n_params; ++i) { + ir_type *param = get_method_param_type(type, i); + if (is_compound_type(param)) { + prop &= ~mtp_property_const; + may_be_const = mtp_no_property; + } + } + if (prop & mtp_property_const) { /* already marked as a const function */ return mtp_property_const; @@ -533,7 +548,7 @@ static mtp_additional_properties check_const_or_pure_function(ir_graph *irg, int end = get_irg_end(irg); endbl = get_nodes_block(end); - prop = mtp_property_const; + prop = may_be_const; ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED); inc_irg_visited(irg); -- 2.20.1