Is there a way to implement an intrinsic that looks like a conditional branch so that it has 2 edges to 2 basic blocks? Taking a step back, I'm trying to make a special branch where Passes treat it just like a regular conditional branch except that it's condition is opaque to everyone, so it isn't removed by optimizations. Additionally, the special branch would codegen (to x86) to something other than the regular branch instructions. Otherwise, I would need to implement the intrinsic as something that returns its opaque value, and I would add a conditional branch that consumes the value right away. Ed
On Mon, Apr 14, 2008 at 5:11 PM, Chris Lattner <sabre at nondot.org> wrote:> Why not something like: > %x = llvm.myintrinsic() > br i1 %x, label %T, label %FRight. That's exactly what I meant in the last paragraph of the original message. The reason for not wanting this is that %x actually always turns out to be 1 (on architectures that support it), so %T is always taken. But this unnecessarily adds overheads with the branch check. However, I do want the semantics of the code to be a conditional branch, so that optimization passes still know about the data flow going into %F. But it wouldn't be the end of the world if I went with this approach. :) Ed
On Mon, 14 Apr 2008, Edward Lee wrote:> Is there a way to implement an intrinsic that looks like a conditional > branch so that it has 2 edges to 2 basic blocks?No. All control flow operators must be terminator instructions.> Taking a step back, I'm trying to make a special branch where Passes > treat it just like a regular conditional branch except that it's > condition is opaque to everyone, so it isn't removed by optimizations. > Additionally, the special branch would codegen (to x86) to something > other than the regular branch instructions.Why not something like: %x = llvm.myintrinsic() br i1 %x, label %T, label %F ? -Chris -- http://nondot.org/sabre/ http://llvm.org/