* Fix mode-switching problem for SH SJLJ exceptions
@ 2007-07-20 14:38 Richard Sandiford
2007-07-31 9:45 ` Richard Sandiford
2007-07-31 15:06 ` Ian Lance Taylor
0 siblings, 2 replies; 3+ messages in thread
From: Richard Sandiford @ 2007-07-20 14:38 UTC (permalink / raw)
To: gcc-patches
Functions that return a value usually end with the sequence:
A: (clobber (reg H))
...
B: (set (reg H) (reg P))
...
C: (use (reg H))
where H is the hard return register and P is the pseudo register
to which return values are assigned.
mode-switching.c uses a specially-split exit block to enforce MODE_EXIT
(the mode required on exit from a function). The code that creates this
block -- create_pre_exit -- tries to find insn B and starts the new block
immediately before (or sometimes immediately after) it.
However, B can be deleted if P is never initialised. In this case,
create_pre_exit splits the block immediately before A instead.
The code only searches for A and B in the fallthrough predecessor
to the exit block; it assumes that P is never initialised if the
block contains neither A nor B.
In some cases B may be made up of several individual insns.
create_pre_exit therefore records the range of modified registers
and stops on the first SET that doesn't assign to part of H.
It then asserts that it has found a SET or CLOBBER for the
whole of H (except in some corner cases).
This shows up a problem on SJLJ targets, where the call to the SJLJ
unregister function is inserted between A and B. If B has been deleted,
the first SET we find may be setting up the argument to that call.
We then stop the search without having found either A or B, so the
assertion triggers.
At this point we have already searched past the call itself, and this
seems bogus. We are supposed to enforce MODE_EXIT _after_ the last call.
I therefore just treated searches that reach a call in the same way as
searches that reach the beginning of a block.
Bootstrapped & regression-tested on x86_64-linux-gnu. Also regression-tested
on sh-elf (multilibs {,-m2,-m3,-m4,-m4/-ml}) and sh-wrs-vxworks. OK to
install?
Richard
gcc/
* mode-switching.c (create_pre_exit): Don't search past calls.
Index: gcc/mode-switching.c
===================================================================
--- gcc/mode-switching.c (revision 126715)
+++ gcc/mode-switching.c (working copy)
@@ -246,6 +246,17 @@ create_pre_exit (int n_entities, int *en
if (INSN_P (return_copy))
{
+ /* When using SJLJ exceptions, the call to the
+ unregister function is inserted between the
+ clobber of the return value and the copy.
+ We do not want to split the block before this
+ or any other call; if we have not found the
+ copy yet, the copy must have been deleted. */
+ if (CALL_P (return_copy))
+ {
+ short_block = 1;
+ break;
+ }
return_copy_pat = PATTERN (return_copy);
switch (GET_CODE (return_copy_pat))
{
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix mode-switching problem for SH SJLJ exceptions
2007-07-20 14:38 Fix mode-switching problem for SH SJLJ exceptions Richard Sandiford
@ 2007-07-31 9:45 ` Richard Sandiford
2007-07-31 15:06 ` Ian Lance Taylor
1 sibling, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2007-07-31 9:45 UTC (permalink / raw)
To: gcc-patches
Ping
Richard Sandiford <richard@codesourcery.com> writes:
> Functions that return a value usually end with the sequence:
>
> A: (clobber (reg H))
> ...
> B: (set (reg H) (reg P))
> ...
> C: (use (reg H))
>
> where H is the hard return register and P is the pseudo register
> to which return values are assigned.
>
> mode-switching.c uses a specially-split exit block to enforce MODE_EXIT
> (the mode required on exit from a function). The code that creates this
> block -- create_pre_exit -- tries to find insn B and starts the new block
> immediately before (or sometimes immediately after) it.
>
> However, B can be deleted if P is never initialised. In this case,
> create_pre_exit splits the block immediately before A instead.
> The code only searches for A and B in the fallthrough predecessor
> to the exit block; it assumes that P is never initialised if the
> block contains neither A nor B.
>
> In some cases B may be made up of several individual insns.
> create_pre_exit therefore records the range of modified registers
> and stops on the first SET that doesn't assign to part of H.
> It then asserts that it has found a SET or CLOBBER for the
> whole of H (except in some corner cases).
>
> This shows up a problem on SJLJ targets, where the call to the SJLJ
> unregister function is inserted between A and B. If B has been deleted,
> the first SET we find may be setting up the argument to that call.
> We then stop the search without having found either A or B, so the
> assertion triggers.
>
> At this point we have already searched past the call itself, and this
> seems bogus. We are supposed to enforce MODE_EXIT _after_ the last call.
> I therefore just treated searches that reach a call in the same way as
> searches that reach the beginning of a block.
>
> Bootstrapped & regression-tested on x86_64-linux-gnu. Also regression-tested
> on sh-elf (multilibs {,-m2,-m3,-m4,-m4/-ml}) and sh-wrs-vxworks. OK to
> install?
>
> Richard
>
>
> gcc/
> * mode-switching.c (create_pre_exit): Don't search past calls.
>
> Index: gcc/mode-switching.c
> ===================================================================
> --- gcc/mode-switching.c (revision 126715)
> +++ gcc/mode-switching.c (working copy)
> @@ -246,6 +246,17 @@ create_pre_exit (int n_entities, int *en
>
> if (INSN_P (return_copy))
> {
> + /* When using SJLJ exceptions, the call to the
> + unregister function is inserted between the
> + clobber of the return value and the copy.
> + We do not want to split the block before this
> + or any other call; if we have not found the
> + copy yet, the copy must have been deleted. */
> + if (CALL_P (return_copy))
> + {
> + short_block = 1;
> + break;
> + }
> return_copy_pat = PATTERN (return_copy);
> switch (GET_CODE (return_copy_pat))
> {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix mode-switching problem for SH SJLJ exceptions
2007-07-20 14:38 Fix mode-switching problem for SH SJLJ exceptions Richard Sandiford
2007-07-31 9:45 ` Richard Sandiford
@ 2007-07-31 15:06 ` Ian Lance Taylor
1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2007-07-31 15:06 UTC (permalink / raw)
To: Richard Sandiford; +Cc: gcc-patches
Richard Sandiford <richard@codesourcery.com> writes:
> gcc/
> * mode-switching.c (create_pre_exit): Don't search past calls.
This is OK.
Thanks.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-31 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-20 14:38 Fix mode-switching problem for SH SJLJ exceptions Richard Sandiford
2007-07-31 9:45 ` Richard Sandiford
2007-07-31 15:06 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).