// Insert the block into the function... right after the block TI lives in.
Function &F = *TIBB->getParent();
- F.getBasicBlockList().insert(TIBB->getNext(), NewBB);
+ Function::iterator FBBI = TIBB;
+ F.getBasicBlockList().insert(++FBBI, NewBB);
// If there are any PHI nodes in DestBB, we need to update them so that they
// merge incoming values from NewBB instead of from TIBB.
// left branch if it is and right branch if not.
Function* F = OrigBlock->getParent();
BasicBlock* NewNode = new BasicBlock("NodeBlock");
- F->getBasicBlockList().insert(OrigBlock->getNext(), NewNode);
+ Function::iterator FI = OrigBlock;
+ F->getBasicBlockList().insert(++FI, NewNode);
ICmpInst* Comp = new ICmpInst(ICmpInst::ICMP_SLT, Val, Pivot.Low, "Pivot");
NewNode->getInstList().push_back(Comp);
{
Function* F = OrigBlock->getParent();
BasicBlock* NewLeaf = new BasicBlock("LeafBlock");
- F->getBasicBlockList().insert(OrigBlock->getNext(), NewLeaf);
+ Function::iterator FI = OrigBlock;
+ F->getBasicBlockList().insert(++FI, NewLeaf);
// Emit comparison
ICmpInst* Comp = NULL;