From 72c631f337f78b20460c508bd8af37fe67a5af37 Mon Sep 17 00:00:00 2001 From: Manuel Mohr Date: Thu, 1 Sep 2011 16:00:31 +0200 Subject: [PATCH] Do not regard functions with compound return types as pure/const. --- ir/opt/funccall.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index 256e32c07..33078331e 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -71,6 +71,23 @@ static unsigned *busy_set; */ #define mtp_temporary mtp_property_inherited +static bool has_compound_return_type(ir_node *node) +{ + ir_type *mtp = get_Call_type(node); + size_t n_res = get_method_n_ress(mtp); + size_t i; + + for (i = 0; i < n_res; ++i) { + ir_type *rtp = get_method_res_type(mtp, i); + + if (is_compound_type(rtp)) { + return true; + } + } + + return false; +} + /** * Walker: Collect all calls to const and pure functions * to lists. Collect all Proj(Call) nodes into a Proj list. @@ -88,6 +105,16 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) /* set the link to NULL for all non-const/pure calls */ set_irn_link(call, NULL); + + /* If the backend's calling convention handles compound return types + * via a hidden pointer argument, it is incorrect to regard this + * call as a call to a const/pure function. + * TODO: This might be overly conservative if the backend uses + * a different calling convention, e.g., for small structs. */ + if (has_compound_return_type(node)) { + return; + } + ptr = get_Call_ptr(call); if (is_Global(ptr)) { ent = get_Global_entity(ptr); -- 2.20.1