[LLVMdev] How to change successor of a regular Basic block
Nick Lewycky
nicholas at mxc.ca
Sat May 1 13:41:14 PDT 2010
ambika wrote:
> Hi,
>
> I am working with regular dominator tree and not MachineDominatorTree.
> I wanted to modify the CFG structure and for that I need to change
> successor of a basic block.
> How can I do that?
The last instruction in a BasicBlock is the TerminatorInst. Replace that
instruction with one that flows into the blocks you want. See
http://llvm.org/docs/LangRef.html#terminators . (Don't forget to update
the phi nodes, if applicable. See BasicBlock::removePredecessor().)
> Or is there a way to cast a BasicBlock to MachineBasicBlock so that i
> can use functions addSucessor and removeSuccessor for the basic block.
No. There's no Machine-etc classes until codegen time.
Nick
More information about the llvm-dev
mailing list