I think the easiest way is to simply create a new unconditional branch instruction, and then replace it with the old one. So something like:
#include "llvm/Transforms/Utils/BasicBlockUtils.h" BranchInst* Old = ... BranchInst* New = BranchInst::Create(Old->getSuccessor(X)); ReplaceInstWithInst(Old, New);
Where X is 0 or 1, depending on whether you want a βtrueβ branch or a βfalseβ branch.
source share