[LLVMdev] unwinds to in the CFG
Chris Lattner
sabre at nondot.org
Fri Apr 4 09:33:32 PDT 2008
On Thu, 3 Apr 2008, Duncan Sands wrote:
>> bb1:
>> %x = invoke i32 @f() to label %normal unwind label %unwind
>> normal:
>> phi i32 [%x, %bb1]
>> ret i32 %x
>> unwind:
>> phi i32 [%x, %bb1] ; illegal
>> ret i32 %x
>>
>> The PHI in %unwind must mention %bb1, but may not refer to %x.
>
> In some sense this PHI is not dominated by its operands. There
> is an edge to %unwind coming out of the invoke, but it is coming
> out of the RHS, i.e. before the assignment to %x. If I wrote
> the invoke as:
On IRC, I suggested that Nicholas consider making the unwind block not be
dominated by *any* instruction in the unwinding block. This gets us out
of weird partial dominance cases and makes the CFG checks simpler. For
example, this would be illegal:
foo: unwinds to bar:
%a = add ...
call ...
...
bar:
use %a
Because foo doesn't dominate bar at all. In practice, unwind blocks (at
least in C++) almost never refer to computation in the unwinding block, so
I think that this is just fine in pratice. For cases where a reference
does exist, it is sufficient to split the block:
foo:
%a = add ..
br foo2
foo2: unwinds to bar
call ...
bar:
use %a
This means that simplifycfg would need to know that it can't merge
foo/foo2, etc.
I think this would significantly simplify the dominance issues with this
approach. Maybe even the quiche eaters will be able to handle it! ;-)
What do you think?
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list