[LLVMdev] RFC: Exception Handling Rewrite

John McCall rjmccall at apple.com
Fri Aug 5 12:01:07 PDT 2011


On Aug 5, 2011, at 11:06 AM, Andrew Trick wrote:
> On Aug 5, 2011, at 10:57 AM, Peter Lawrence wrote:
>> However it seems that if a landingpad-block has multiple predecessors (often the case,
>> multiple InvokeInst in the main body of a try-statement all go to the same landingpad-
>> block), then you cannot move the LandingpadInst in order to break a critical edge unless
>> you do it for _all_  landingpad-block predecessor edges simultaneously, but that seems
>> to be a messy conclusion (being forced to split other edges that don't need to be split).

Yes, this is why we're not going to have SplitCriticalEdge
succeed on landing pad edges, at least by default.  It's not conceptually
impossible, but it is significantly more invasive than a normal
edge-splitting, and pretty much every client would need to be
updated to handle it.

> I think this will be done lazily to avoid excessive splitting as in:
> 
> Call1 -> LP
> Call2 -> LP
> Call3 -> LP
> 
> => split Call1
> 
> Call1 -> LP-split -> LP-remainder
> Call2 -> LP-split-merge -> LP-remainder
> Call3 -> LP-split-merge -> LP-remainder

Yes, this is precisely the transformation required for splitting a critical
edge to a landing pad.

If LP has n predecessors and k phis, such that looks like this:

  LP:
    %phi_i = phi [ %value_{i,1}, %call_1 ] .. [ %value_{i,n}, %call_n ]
    %lpad = landingpad LP-args
    LP-instructions...

then the three new blocks look like this:

  LP-split:
    %lpad-split = landingpad LP-args
    br label %LP-remainder

  LP-split-merge:
    %phi-split-merge_i = phi [ %value_{i,2}, %call_2 ] .. [ %value_{i,n}, %call_n ]
    %lpad-split-merge = landingpad LP-args
    br label %LP-remainder

  LP-remainder:
    %phi_i = phi [ %value_{i,1}, %LP-split ], [ %phi-split-merge, %LP-split-merge ]
    %lpad = phi [ %lpad-split, %LP-split ], [ %lpad-split-merge, %LP-split-merge ]
    LP-instructions...

In practice, we would want to recognize that LP has the form of an
LP-split-merge, with associated LP-remainder, and we would just re-use
that as our new LP-split-merge block, adding incoming values to the phis
in the LP-remainder as appropriate.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110805/4fa80171/attachment.html>


More information about the llvm-dev mailing list