Potential bug in stmt.c (expand_value_return)

Richard Henderson rth@cygnus.com
Wed Feb 2 13:43:00 GMT 2000


On Wed, Feb 02, 2000 at 09:26:16PM +0300, Denis Chertykov wrote:
> `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.  */

There must be a bug in the cleanup code.  As the comment says,
it's supposed to happen before the return register is loaded.
Anything else is dreadfully wrong, because the cleanups include
destructor calls, which can call functions.

> Why emit USEs was removed ?

Because stupid.c should have been the only one needing them,
and that was removed.

> 	* 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

If you adjust the stack before the return register is loaded,
you don't need the use. 

But we should still figure out why the adjustment isn't being put
in the right place by one of expand_null_return_1's subroutines,
as there could be a larger bug hiding in there.


r~


More information about the Gcc mailing list