Florian Merz
2010-Feb-08 15:49 UTC
[LLVMdev] converting an unconditional into a conditional branch
Hi, I'm learning to use the llvm API, but I got a question for which I haven't found a good answer yet: What is the best way to turn an unconditional branch into a conditional branch? All I want to do is add two more operands, a successor and a condition. But no matter how I try to do this any one of setCondition()/setOperand()/setSuccessor() causes an assertion like these: Cannot set condition of unconditional branch! Successor # out of range for Branch! setOperand() out of range! Can this only be done by completely replacing the unconditional branch instruction with a new, conditional one or is there a method with which I can implicitly turn an unconditional branch into a conditional one by adding a condition and a successor? I'd be glad if anyone could give me a hint on how to do this most elegantly. Regards, Florian
Devang Patel
2010-Feb-10 17:48 UTC
[LLVMdev] converting an unconditional into a conditional branch
On Mon, Feb 8, 2010 at 3:49 PM, Florian Merz <florian.merz at kit.edu> wrote:> Hi, > > I'm learning to use the llvm API, but I got a question for which I haven't > found a good answer yet: > > What is the best way to turn an unconditional branch into a conditional > branch? All I want to do is add two more operands, a successor and a > condition. But no matter how I try to do this any one of > setCondition()/setOperand()/setSuccessor() causes an assertion like these: > > Cannot set condition of unconditional branch! > Successor # out of range for Branch! > setOperand() out of range! > > Can this only be done by completely replacing the unconditional branch > instruction with a new, conditional one or is there a method with which I can > implicitly turn an unconditional branch into a conditional one by adding a > condition and a successor?Replacing the unconditional branch instruction is appropriate here. - Devang> > I'd be glad if anyone could give me a hint on how to do this most elegantly. > > Regards, > Florian > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >