Reputation: 21625
In LLVM, how can I have generate a branch instruction that jumps directly, rather than having if-else. I know there is LLVM::BranchInst class, but don't know how to use it for this purpose, or do I need to use some other class?
Upvotes: 3
Views: 3303
Reputation: 34401
Use this method:
static BranchInst * Create (BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
The first argument is where you are jumping to and the second one is where created instruction should be placed.
Upvotes: 2
Reputation: 40829
You need an unconditional branch:
static BranchInst * llvm::BranchInst::Create(BasicBlock *IfTrue,
Instruction *InsertBefore = 0)
static BranchInst * llvm::BranchInst::Create(BasicBlock *IfTrue,
BasicBlock *InsertAtEnd)
Upvotes: 4