[LLVMdev] unwinds to in the CFG
Duncan Sands
baldrick at free.fr
Thu Apr 3 11:25:46 PDT 2008
> In LLVM the rule is that an instruction must be dominated by its
> operands.
...
> We already have this issue with invoke. Consider:
>
> 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:
invoke i32 @f() <= this may branch to %unwind
place the result in %x
then it is clear that the phi is dominated by the call part of
the invoke but not the result copying part. Likewise for something
like
bb1: unwinds to %cleanup
%x = udiv i32 @foo, @bar <= The udiv is always executed before %cleanup, but not the assignment to %x
ret i32 %x
cleanup:
%y = phi i32 [%x, bb1]
So maybe it is helpful to think of instructions as corresponding to
a LHS and a RHS node in the cfg, with an edge from RHS to LHS, and
with exceptional edges coming out of the RHS node.
Ciao,
Duncan.
More information about the llvm-dev
mailing list