[LLVMdev] RFC: Exception Handling Proposal II

Bill Wendling wendling at apple.com
Sun Nov 28 02:20:54 PST 2010


On Nov 27, 2010, at 4:57 PM, John McCall wrote:

> On Nov 25, 2010, at 3:03 AM, Duncan Sands wrote:
>> I'm pointing out that if the invoke instruction
>> is removed and catch information is attached to entire basic blocks, then if no
>> care is taken then it is perfectly possible to use %x before it is defined as
>> explained in my previous email, blowing up the entire LLVM system.  Clearly the
>> solution is to not allow this by not allowing values defined in a basic block
>> to be used in a handler for that block;
> 
> If we take this route — and I think we should, although I'd like to see region
> chaining in first — I see two reasonable solutions.  The first is what you've
> said, that effectively there's an edge from the beginning of the block;  the
> second is a slight twist, that the edge leaves from the end of the phis.  I
> think the latter will greatly simplify every transformation which ever inserts
> a phi, and in particular mem2reg.  Since phis can't throw, it should be
> equivalent anyway.

Wouldn't this route make otherwise value programs invalid? For instance:

entry:
  %x = alloca i32
  br label try

try: unwinds to %landing.pad
  %x1 = add i32 37, 927
  call @foo()
  br label %normal.edge

landing.pad: landingpad
  ; Code that prints the value of %x1

We expect the value printed to be 964, but if we don't allow %x1 to be accessible then we get garbage or an assert...

Or am I missing something? :-)

-bw





More information about the llvm-dev mailing list