[LLVMdev] Basic Block Chaining

Chris Lattner sabre at nondot.org
Thu Nov 20 11:49:01 PST 2003


> // Create a new branch instruction, jumping to the 'New' block.  Specify
> // where in the LLVM program to insert it, in this case, at the end of the
> // CurrentEnd block.
> new BranchInst(New, CurrentEnd.end());

Actually, I just realized that this won't work.  This will attempt to
dereference the end iterator, which will cause an assertion to fire.
Instead, use the (just now checked in) constructor that takes an 'insert
at end' block:

new BranchInst(New, 0, 0, CurrentEnd);

The 0's are to indicate that an unconditional branch should be made, not a
conditional branch.

I added some documentation for all of the return and branch ctors
available here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031117/009698.html

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list