[LLVMdev] RFC: Exception Handling Proposal Revised

Bill Wendling wendling at apple.com
Wed Dec 1 11:15:26 PST 2010


On Dec 1, 2010, at 2:37 AM, Renato Golin wrote:

> On 1 December 2010 09:46, Bill Wendling <wendling at apple.com> wrote:
>> Nor these. Basically, I want the basic block that's labeled a "landing pad" to be jumped to by only a dispatch resume or unwind edge of invoke. We could do this with the c.dtor and ch.int here, but it would mean inserting useless "cleanup dispatches" that only resume to the block (see onto.catch.handlers for an example).
> 
> Hi Bill,
> 
> All cleanups come from invoke's unwinds (from foo's call) and all
> catch handlers come from the main catch dispatch, so for that rule,
> they all should have it. Or that's what I understood... ;)
> 
> Also, now I noticed a few things in your IR, could be just typos...
> (ie. I'm not being an ass, just checking I got it right) ;)
> 
> 1. Your BB flow seem odd in the try block. You call foo() four times
> and then call the Ctors, rather than interpolating them as in the
> source code (otherwise, all calls to foo should unwind to the catch
> area, not cleanups).
> 
I think you mean that it calls the Dtors on %c, %b, and %a. :-) It optimized the creation of the objects by not calling the empty constructors. bb1, bb2, and bb3 are the normal calls to the d'tors that we expect.

> 2. In catch.handlers, the resume label is to %onto.catch.handlers, right?
> 
Oh…I forgot to fill that in. It should to go %yikes.

> 3. In onto.catch.handlers you resume to %lpad. Which basic-block is
> this? Shouldn't this be a "resume_unwinding" call of some sort (if Q2
> is right)?
> 
This was necessary to keep the invariant that only resume or unwind edges may jump to a landing pad (%lpad in this instance). Otherwise, I would have the invoke in a.dtor to directly to %lpad on the "normal" edge.

> 4. Your catch handlers return void, shouldn't then branch to %return
> instead? In this case, a front-end would probably call that label a
> "%finally" and that would branch to %return, or return directly.
> 
They could. It's an optimization that the back-end normally does. :-)

> Which brings me to my final question: In languages where the finally
> HAS to run, like Java, would that be a simple cleanup regions or do we
> need something special from catch's dispatch's resume AND %finally
> block?
> 
I need to see how we do things today (Objective-C also has finally blocks). But I suspect that it will be a matter of having the catch handlers jumping to the finally block. In other words, I don't suspect that we need a different mechanism to handle this.

-bw

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101201/ecd3bfb9/attachment.html>


More information about the llvm-dev mailing list