How to change successor of a regular Basic block

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?

Or is there a way to cast a BasicBlock to MachineBasicBlock so that i can use functions addSucessor and removeSuccessor for the basic block.

It will be great if someone can help.

regards,
Ambika

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