Function clobber_return_register
Richard Henderson
rth@redhat.com
Wed Dec 11 16:44:00 GMT 2002
On Wed, Dec 11, 2002 at 06:59:57PM -0500, Richard Kenner wrote:
> Can somebody explain what this function is for? There are no comments
> in front of this function (or do_clobber_return_reg) saying what it does.
It generates a clobber of the return register. I thought that
was pretty obvious.
Oh you mean *why*. See expand_function_end and
check_function_return_warnings. In particular,
/* Before the return label (if any), clobber the return
registers so that they are not propagated live to the rest of
the function. This can only happen with functions that drop
through; if there had been a return statement, there would
have either been a return rtx, or a jump to the return label.
We delay actual code generation after the current_function_value_rtx
is computed. */
clobber_after = get_last_insn ();
In expand_function_end, note that immediately afterward, the return_label
is emitted, followed by cleanups.
In check_function_return_warnings, note that we've already deleted
unreachable code, so if the clobber insn still exists, it means that
the function reaches the end without returning a value.
> The test case is this tiny Ada code:
>
> function Tretcln return Integer is
> S : String := Integer'Image (1);
> function Ret1 return integer is begin return 1; end;
> begin
> return Ret1;
> end Tretcln;
>
> and the issue is that there is a cleanup (due to the 'Image)
> for this function.
> Due to the CLOBBER and USE now being in the same basic block, that block is
> marked as not having $0 live, so the restore of $0 is deleted as a dead insn
> and thus the return value of Ret1 is being lost in the return of Tretcln.
Since this works for C++, I can only guess that the Ada front
end isn't generating either returns or cleanups the way the
back end is expecting.
r~
More information about the Gcc
mailing list