This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Fun with exceptions -- opinions needed


Hi,

On Fri, 13 Jun 2003 law@redhat.com wrote:

> try {
>       i = get (strm.5)
>     }
> catch { };
> if (i != 0)
>
> OK.  So think about what happens if "get" throws an exception in
> the statement "i = get (strm.5)".  Right, the side effect of assigning
> a new value to "i" does not happen.

There was some thread about exactly this problem some months ago (it was
in Java, but that doesn't matter here).  IIRC the actual problem was, that
something _was_ assigned to the pseudo representing 'i', although the
function threw (thereby overwriting the initial value).

The conclusion was that we have to force the assignment to go through a
temp (and make various flow-unaware passes (cse?, combine?) not optimize
the assignment away).

> I'm not real hot on the idea of trying to teach the optimizers about
> this little gem.  However, the idea of always copying the value through
> a temporary isn't all that appealing either, though it appears to be
> a lot cleaner.

What alternatives do you have in mind?  The copies are an explicit
representation of the necessary data and control flow in this situation
(namely the separation of the side-effect of calling the function from the
side-effect of overwriting the variable).  The only overhead I see are the
number of temporaries which have to be created, and those could arguably
all be the same (will anyway be renamed to different SSA names then).
The copy instructions themself will be optimized away by a coalescer if
possible.  I guess that's a low price to pay for cleanliness.


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]