[LLVMdev] Replacing unconditional branches with conditional ones

Nick Johnson npjohnso at cs.princeton.edu
Mon Jun 8 01:12:35 PDT 2009


You should also call .eraseFromParent() on the old branch instruction.


On Mon, Jun 8, 2009 at 12:43 PM, Cain, Harel<HCain at nds.com> wrote:
> Hi all,
> Somewhat of a newbie's question, hope you can help me out.
> I'm trying to turn unconditional BranchInst's into conditional ones (with a
> condition I'm supplying) branching between the original target and a basic
> block of my choice.
> Apparently the way to do that is to create a new conditional BranchInst and
> remove the unconditional one from its basic block. However when removing the
> unconditional branch, its target's predecessor list seems not to be updated,
> so that the end result is for the original target to have duplicates in its
> predecessor list, sometimes even an a "null" predecessor for some reason.
> Can you advise what's the safest, recommended way to replace an
> unconditional branch with a conditional one?
> Thanks,
> Harel
> ________________________________
> This e-mail is confidential, the property of NDS Ltd and intended for the
> addressee only. Any dissemination, copying or distribution of this message
> or any attachments by anyone other than the intended recipient is strictly
> prohibited. If you have received this message in error, please immediately
> notify the postmaster at nds.com and destroy the original message. Messages
> sent to and from NDS may be monitored. NDS cannot guarantee any message
> delivery method is secure or error-free. Information could be intercepted,
> corrupted, lost, destroyed, arrive late or incomplete, or contain viruses.
> We do not accept responsibility for any errors or omissions in this message
> and/or attachment that arise as a result of transmission. You should carry
> out your own virus checks before opening any attachment. Any views or
> opinions presented are solely those of the author and do not necessarily
> represent those of NDS.
> To protect the environment please do not print this e-mail unless necessary.
> NDS Limited Registered Office: One London Road, Staines,Middlesex TW18 4EX,
> United Kingdom. A company registered in England and Wales Registered no.
> 3080780 VAT no. GB 603 8808 40-00
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Nick Johnson

More information about the llvm-dev mailing list