This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix rtl-opt/17186
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 8 Sep 2004 12:34:11 -0700
- Subject: fix rtl-opt/17186
The problem here is directly related to the fall-off-the-end
path in the test case:
double foo()
{
int i;
double d;
if (i)
bar();
else
if (d) return 0;
}
Combined with the path that *does* return a value, the initial
rtl generated looks like
...
(clobber st0)
return_label:
(set st0 return_value)
(use st0)
(return)
After register allocation, return_value is replaced with st1.
But when it comes time for reg-stack, we can't find a live
value for st1 on all incoming edges, so we abort.
The following adds a jump around the setting of the hard return
register there just before the return. This means that we aren't
looking for st1 to be live in reg-stack, which means that we do
the right thing and load up a NaN in st0 to satisfy the stack
height requirements of the ABI.
Applied to mainline and 3.4.
r~
PR rtl-opt/17186
* function.c (expand_function_end): Have fall-off-the-end
return path jump around return register setup.
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.573
diff -c -p -d -r1.573 function.c
*** function.c 8 Sep 2004 18:44:56 -0000 1.573
--- function.c 8 Sep 2004 19:21:16 -0000
*************** expand_function_end (void)
*** 4411,4430 ****
/* Emit the actual code to clobber return register. */
{
! rtx seq, after;
start_sequence ();
clobber_return_register ();
seq = get_insns ();
end_sequence ();
! after = emit_insn_after (seq, clobber_after);
}
! /* Output the label for the naked return from the function, if one is
! expected. This is currently used only by __builtin_return. */
! if (naked_return_label)
! emit_label (naked_return_label);
/* ??? This should no longer be necessary since stupid is no longer with
us, but there are some parts of the compiler (eg reload_combine, and
--- 4411,4429 ----
/* Emit the actual code to clobber return register. */
{
! rtx seq;
start_sequence ();
clobber_return_register ();
+ expand_naked_return ();
seq = get_insns ();
end_sequence ();
! emit_insn_after (seq, clobber_after);
}
! /* Output the label for the naked return from the function. */
! emit_label (naked_return_label);
/* ??? This should no longer be necessary since stupid is no longer with
us, but there are some parts of the compiler (eg reload_combine, and