From: Richard Biener Date: Thu, 6 May 2021 07:44:49 +0000 (+0200) Subject: Fix IPA SRA removal of DECL_BY_REFERENCE return X-Git-Tag: basepoints/gcc-13~7751 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1698f496c5ee96b980ba97f5cd5f56b633e4afe0;p=thirdparty%2Fgcc.git Fix IPA SRA removal of DECL_BY_REFERENCE return While doing bogus call LHS removal I noticed that cloning with dropping a return value creates a bogus replacement for a DECL_BY_REFERENCE DECL_RESULT, resulting in MEM_REFs of aggregates rather than pointers. The following fixes this latent issue. 2021-05-06 Richard Biener * tree-inline.c (tree_function_versioning): Fix DECL_BY_REFERENCE return variable removal. --- diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 49a5850f4104..8f945b88c12f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -6367,6 +6367,8 @@ tree_function_versioning (tree old_decl, tree new_decl, tree resdecl_repl = copy_result_decl_to_var (DECL_RESULT (old_decl), &id); declare_inline_vars (NULL, resdecl_repl); + if (DECL_BY_REFERENCE (DECL_RESULT (old_decl))) + resdecl_repl = build_fold_addr_expr (resdecl_repl); insert_decl_map (&id, DECL_RESULT (old_decl), resdecl_repl); DECL_RESULT (new_decl)