aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-09-17 12:58:02 +0200
committerEric Botcazou <ebotcazou@adacore.com>2020-09-17 13:00:24 +0200
commit225a08220e444371ae4867b3e2ace275d30af3d3 (patch)
tree9b0e3d8c34a1b39d8acb77ad87cc19362865dc2a /gcc/function.c
parent80cbca32464ae05931c0ae425eec7d1f373946eb (diff)
downloadgcc-225a08220e444371ae4867b3e2ace275d30af3d3.zip
gcc-225a08220e444371ae4867b3e2ace275d30af3d3.tar.gz
gcc-225a08220e444371ae4867b3e2ace275d30af3d3.tar.bz2
Fix assertion checking failure with tail call
gcc/ChangeLog: PR middle-end/97078 * function.c (use_register_for_decl): Test cfun->tail_call_marked for a parameter here instead of... (assign_parm_setup_reg): ...here. gcc/testsuite/ChangeLog: * gcc.dg/pr97078.c: New test.
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/function.c b/gcc/function.c
index c4c9930..c612959 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2237,6 +2237,11 @@ use_register_for_decl (const_tree decl)
if (optimize)
return true;
+ /* Thunks force a tail call even at -O0 so we need to avoid creating a
+ dangling reference in case the parameter is passed by reference. */
+ if (TREE_CODE (decl) == PARM_DECL && cfun->tail_call_marked)
+ return true;
+
if (!DECL_REGISTER (decl))
return false;
@@ -3328,9 +3333,8 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm,
of the parameter instead. */
if (data->arg.pass_by_reference && TYPE_MODE (TREE_TYPE (parm)) != BLKmode)
{
- /* Use a stack slot for debugging purposes, except if a tail call is
- involved because this would create a dangling reference. */
- if (use_register_for_decl (parm) || cfun->tail_call_marked)
+ /* Use a stack slot for debugging purposes if possible. */
+ if (use_register_for_decl (parm))
{
parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm)));
mark_user_reg (parmreg);