public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* PR2975
@ 2001-06-05 11:47 Mark Mitchell
  2001-06-05 12:08 ` PR2975 Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Mitchell @ 2001-06-05 11:47 UTC (permalink / raw)
  To: Richard Henderson, Nathan Sidwell; +Cc: gcc

Richard --

  I've analyzed this failure a bit further.  The problem is that we
are in expand_call, and we decide to try making a sibcall variant of
the call.  In so doing, we find that there are some exception regions
required for the arguments.  That causes us to set sibcall_failure and
bail out.  Unfortunately, this hackery that you can I conspired on a
while back:

      if (pass == 0)
	{
	  /* Undo the fake expand_start_target_temps we did earlier.  If
	     there had been any cleanups created, we've already set
	     sibcall_failure.  */
	  expand_end_target_temps ();
	}

does not work with the new EH scheme because the regions we created
while evaluating the arguments live on.  As a result, we end up with
instructions chained on to the exception_handler_labels list that were
never actually emitted into the instruction stream, which is bogus.

  If the compiler was written in just about any language other than C,
we could throw an exception when we realized we were about to create
an exception region -- before actually creating it -- and get back to
expand_call without doing any damage.  This would be faster, too,
since we wouldn't actually finish generating all the code for the
call.  Needless to say, this is difficult in C, and I don't fancy
sticking setjmp/longjmp all over the place.

  There is a lying comment in sibcall.c that says:

  /* We do not perform these calls when flag_exceptions is true, so this
     is probably a NOP at the current time.  However, we may want to support

But, we do call this function with flag_exceptions.

  I think that the easiest short-term fix is to make the comment tell
the truth: turn off flag_sibling_calls when flag_exceptions is true.
That is OK for GCC 3.0 because it is not a regression from GCC 2.95,
where we did not have the optimization at all.

  Ideally, we would find a way to make this all work better -- but
we've also agreed that sibling call optimization should happen on
trees before we start generating RTL and once we do that all of this
will be a no-op, so I'm not sure it's even worth working hard on this
at the moment.  

  In any case, if you happen to know how to fix this easily, feel free
to do so!  I'll check in my "fix", but you can blow it away and do
something better if you like.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PR2975
  2001-06-05 11:47 PR2975 Mark Mitchell
@ 2001-06-05 12:08 ` Richard Henderson
  2001-06-05 15:36   ` PR2975 Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2001-06-05 12:08 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Nathan Sidwell, gcc

On Tue, Jun 05, 2001 at 11:47:12AM -0700, Mark Mitchell wrote:
> 	  /* Undo the fake expand_start_target_temps we did earlier.  If
> 	     there had been any cleanups created, we've already set
> 	     sibcall_failure.  */
> 	  expand_end_target_temps ();
> 
> does not work with the new EH scheme because the regions we created
> while evaluating the arguments live on.

Ug.

>   I think that the easiest short-term fix is to make the comment tell
> the truth: turn off flag_sibling_calls when flag_exceptions is true.

I don't have any bright ideas.  I think just letting go with 
that is the best we'll be able to do for 3.0.



r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PR2975
  2001-06-05 12:08 ` PR2975 Richard Henderson
@ 2001-06-05 15:36   ` Richard Henderson
  2001-06-05 15:41     ` PR2975 Mark Mitchell
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2001-06-05 15:36 UTC (permalink / raw)
  To: Mark Mitchell, Nathan Sidwell, gcc

On Tue, Jun 05, 2001 at 12:08:11PM -0700, Richard Henderson wrote:
> >   I think that the easiest short-term fix is to make the comment tell
> > the truth: turn off flag_sibling_calls when flag_exceptions is true.
> 
> I don't have any bright ideas.  I think just letting go with 
> that is the best we'll be able to do for 3.0.

Actually, I do have a bright idea.

Currently we build the sibcall version first, (attempt to) abort if we 
see exception regions created, and build the normal version second.

Instead we should build the normal version first and look to see if we
created any exception regions (and left them open) in the process.  If
so, don't build the sibcall version at all.  Therefore we have nothing
to undo.

This situation may be detected by noticing that cfun->eh->cur_region
changed.  (Though as-written we'd need an accessor in except.c because
cfun->eh is private.)

I may work on a patch for this later...


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PR2975
  2001-06-05 15:36   ` PR2975 Richard Henderson
@ 2001-06-05 15:41     ` Mark Mitchell
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 2001-06-05 15:41 UTC (permalink / raw)
  To: rth; +Cc: nathan, gcc

>>>>> "Richard" == Richard Henderson <rth@redhat.com> writes:

    Richard> Actually, I do have a bright idea.

:-)

    Richard> Instead we should build the normal version first and look
    Richard> to see if we created any exception regions (and left them
    Richard> open) in the process.  If so, don't build the sibcall
    Richard> version at all.  Therefore we have nothing to undo.

That sounds plausible.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-06-05 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-05 11:47 PR2975 Mark Mitchell
2001-06-05 12:08 ` PR2975 Richard Henderson
2001-06-05 15:36   ` PR2975 Richard Henderson
2001-06-05 15:41     ` PR2975 Mark Mitchell

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).