This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Potential bug in stmt.c (expand_value_return)
- To: gcc at gcc dot gnu dot org
- Subject: Potential bug in stmt.c (expand_value_return)
- From: Denis Chertykov <denisc at overta dot ru>
- Date: Wed, 2 Feb 2000 21:26:16 +0300
- Cc: gcc-patches at gcc dot gnu dot org
I have founded bug in stmt.c (expand_value_return) which actual for my
AVR port.
`expand_value_return' first generates move insn for return_reg
and after that generates stack adjust insn.
Fragment from `expand_value_return':
else
emit_move_insn (return_reg, val);
}
/* Does any pending block have cleanups? */
while (block && block->data.block.cleanups == 0)
block = block->next;
/* If yes, use a goto to return, since that runs cleanups.
Use LAST_INSN to put cleanups *before* the move insn emitted above. */
/* `do_pending_stack_adjust' executed here ! */
expand_null_return_1 (last_insn, block != 0);
}
AVR port can't adjust stack without additional register.
reload pass allocates such register, but this register equal to
return_reg - it's a bug.
I have a simple solution for this problem.
Emit USEs for return_reg after stack adjusting.
But I have founded this record in ChangeLog.
2000-01-19 Richard Henderson <rth@cygnus.com>
...
* stmt.c (expand_value_return): Don't emit USEs for stupid.
...
Why emit USEs was removed ?
My path for stmt.c:
Wed Feb 2 21:16:10 2000 Denis Chertykov <denisc@overta.ru>
* stmt.c (expand_null_return): adjust stack without
expand_null_return_1
(expand_value_return): adjust stack without
expand_null_return_1. Generate USEs for return register after
stack adjusting.
(expand_null_return_1): now don't adjust stack
*** stmt.c 2000/02/01 20:41:51 1.1
--- stmt.c 2000/02/02 18:14:52
*************** expand_null_return ()
*** 2684,2689 ****
--- 2684,2693 ----
while (block && block->data.block.cleanups == 0)
block = block->next;
+ /* Restore stack value */
+ clear_pending_stack_adjust ();
+ do_pending_stack_adjust ();
+
/* If yes, use a goto to return, since that runs cleanups. */
expand_null_return_1 (last_insn, block != 0);
*************** expand_value_return (val)
*** 2727,2732 ****
--- 2731,2743 ----
while (block && block->data.block.cleanups == 0)
block = block->next;
+ /* We must adjust stach before return_reg will be REGDEAD */
+ clear_pending_stack_adjust ();
+ do_pending_stack_adjust ();
+
+ /* return_reg will be DEAD only after this insn */
+ diddle_return_value (USE);
+
/* If yes, use a goto to return, since that runs cleanups.
Use LAST_INSN to put cleanups *before* the move insn emitted above. */
*************** expand_null_return_1 (last_insn, use_got
*** 2746,2753 ****
{
rtx end_label = cleanup_label ? cleanup_label : return_label;
- clear_pending_stack_adjust ();
- do_pending_stack_adjust ();
last_expr_type = 0;
/* PCC-struct return always uses an epilogue. */
--- 2757,2762 ----