pythonic
pythonic

Reputation: 21625

Branch instruction with direct jump in LLVM

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

Answers (2)

arrowd
arrowd

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

Michael F
Michael F

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

Related Questions