[LLVMdev] invoke semantics

Dan Gohman gohman at apple.com
Fri May 22 11:45:18 PDT 2009


On May 22, 2009, at 10:13 AM, Dale Johannesen wrote:

> Should we document it then?  Invokes are confusing enough without
> relying on undocumented behavior:)

It'd be good for someone actually familiar with invoke could comment
on this. Specifically, in the following testcase, the return value of
the invoke is used in the unwind destination, which is not reachable
from the normal destination. Should this be valid?

define i32 @foo() {
entry:
   %t = invoke i32 @bar() to label %normal unwind label %lpad

normal:
   ret i32 0

lpad:
   ret i32 %t
}

declare i32 @bar()


If it's valid, it leads to the following quirky situation:

define i32 @foo() {
entry:
   %t = invoke i32 @bar() to label %normal unwind label %lpad

normal:
   %a = add i32 %t, 1
   ...

lpad:
   %b = add i32 %t, 1
   ...
}

The two adds compute the same value, but it's not possible to
CSE them because there's nowhere to place an instruction that
would be dominated by the operands (the invoke) that would
also dominate all the uses.

Dan




More information about the llvm-dev mailing list