[gcc r11-3257] Fix assertion checking failure with tail call
Eric Botcazou
ebotcazou@gcc.gnu.org
Thu Sep 17 11:01:05 GMT 2020
https://gcc.gnu.org/g:225a08220e444371ae4867b3e2ace275d30af3d3
commit r11-3257-g225a08220e444371ae4867b3e2ace275d30af3d3
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Thu Sep 17 12:58:02 2020 +0200
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.
Diff:
---
gcc/function.c | 10 +++++++---
gcc/testsuite/gcc.dg/pr97078.c | 9 +++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/gcc/function.c b/gcc/function.c
index c4c9930d725..c6129593b9b 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);
diff --git a/gcc/testsuite/gcc.dg/pr97078.c b/gcc/testsuite/gcc.dg/pr97078.c
new file mode 100644
index 00000000000..997d5fb8dd9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97078.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffloat-store" } */
+
+extern void foo (long double);
+
+void bar (long double d)
+{
+ foo (d);
+}
More information about the Gcc-cvs
mailing list