public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix IPA SRA removal of DECL_BY_REFERENCE return
@ 2021-05-06  7:48 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-05-06  7:48 UTC (permalink / raw)
  To: gcc-patches

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.

I don't have a testcase that ICEs without doing a bogus DSE
transform though.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

2021-05-06  Richard Biener  <rguenther@suse.de>

	* tree-inline.c (tree_function_versioning): Fix DECL_BY_REFERENCE
	return variable removal.
---
 gcc/tree-inline.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 49a5850f410..8f945b88c12 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)
-- 
2.26.2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-06  8:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  7:48 [PATCH] Fix IPA SRA removal of DECL_BY_REFERENCE return Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).