[LLVMdev] unwinds to in the CFG
sabre at nondot.org
Fri Apr 4 09:33:32 PDT 2008
On Thu, 3 Apr 2008, Duncan Sands wrote:
>> %x = invoke i32 @f() to label %normal unwind label %unwind
>> phi i32 [%x, %bb1]
>> ret i32 %x
>> 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 ...
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:
%a = add ..
foo2: unwinds to bar
This means that simplifycfg would need to know that it can't merge
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?
More information about the llvm-dev