BasicBlock Cloning

Hi

I have clone a basic block using CloneBasicBlock function but it does not clone the predecessor with it. I am not able to figure out, how to set the predecessor of the cloned basic block.

Tarun

Hi

I have clone a basic block using CloneBasicBlock function but it does not clone the predecessor with it. I am not able to figure out, how to set the predecessor of the cloned basic block.

LLVM’s CFG is explicitly maintained by the terminator instructions within each basic block. In order to change the CFG, you have to change the terminator instructions.

To make BasicBlock B a successor of BasicBlock A, you have to modify or replace BasicBlock A’s terminator instruction to branch to BasicBlock B.

– John T.

Thank you john that has really worked for me