From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] middle-end/107679 - fix SSA rewrite of clobber of parameter
Date: Wed, 16 Nov 2022 16:34:08 +0100 (CET) [thread overview]
Message-ID: <20221116153408.86FA313480@imap2.suse-dmz.suse.de> (raw)
When the frontend clobbers a parameter and that parameter gets
rewritten into SSA then we ICE because we didn't expect this. Avoid
using the parameter decl to create a SSA default def in this case.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR middle-end/107679
* tree-into-ssa.cc (maybe_register_def): Use new temporary if
we require an uninitialized value for a parameter decl.
* gfortran.dg/pr107679.f90: New testcase.
---
gcc/testsuite/gfortran.dg/pr107679.f90 | 9 +++++++++
gcc/tree-into-ssa.cc | 8 ++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/pr107679.f90
diff --git a/gcc/testsuite/gfortran.dg/pr107679.f90 b/gcc/testsuite/gfortran.dg/pr107679.f90
new file mode 100644
index 00000000000..33a52fb5ef2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107679.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+subroutine s1(x)
+ integer, intent(out) :: x
+end
+subroutine s2(z)
+ integer, value :: z
+ call s1(z)
+end
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index d13fb720b37..f21ed2bea3f 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -1911,13 +1911,17 @@ maybe_register_def (def_operand_p def_p, gimple *stmt,
{
if (gimple_clobber_p (stmt) && is_gimple_reg (sym))
{
- gcc_checking_assert (VAR_P (sym));
+ tree defvar;
+ if (VAR_P (sym))
+ defvar = sym;
+ else
+ defvar = create_tmp_reg (TREE_TYPE (sym));
/* Replace clobber stmts with a default def. This new use of a
default definition may make it look like SSA_NAMEs have
conflicting lifetimes, so we need special code to let them
coalesce properly. */
to_delete = true;
- def = get_or_create_ssa_default_def (cfun, sym);
+ def = get_or_create_ssa_default_def (cfun, defvar);
}
else
{
--
2.35.3
reply other threads:[~2022-11-16 15:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221116153408.86FA313480@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).