From 8a5f3663f8de45b7030dfe7ce962783dc1a19885 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 16 Nov 2022 13:57:14 +0100 Subject: [PATCH] middle-end/107679 - fix SSA rewrite of clobber of parameter 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. 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 0000000..33a52fb --- /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 d13fb72..f21ed2b 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.7.4