// without actually branching to it (the exit block should be dominated by the
// loop header, not the preheader).
assert(!L->contains(ExitBlock) && "Exit block is in the loop?");
- BasicBlock *NewExit = SplitBlock(ExitBlock, ExitBlock->begin(), DT, LI);
+ BasicBlock *NewExit = SplitBlock(ExitBlock, &ExitBlock->front(), DT, LI);
// Okay, now we have a position to branch from and a position to branch to,
// insert the new conditional branch.
// Check if this loop will execute any side-effecting instructions (e.g.
// stores, calls, volatile loads) in the part of the loop that the code
// *would* execute. Check the header first.
- for (BasicBlock::iterator I : *CurrentBB)
- if (I->mayHaveSideEffects())
+ for (Instruction &I : *CurrentBB)
+ if (I.mayHaveSideEffects())
return false;
// FIXME: add check for constant foldable switch instructions.
// Splice the newly inserted blocks into the function right before the
// original preheader.
- F->getBasicBlockList().splice(NewPreheader, F->getBasicBlockList(),
- NewBlocks[0], F->end());
+ F->getBasicBlockList().splice(NewPreheader->getIterator(),
+ F->getBasicBlockList(),
+ NewBlocks[0]->getIterator(), F->end());
// FIXME: We could register any cloned assumptions instead of clearing the
// whole function's cache.
if (LandingPadInst *LPad = NewExit->getLandingPadInst()) {
PHINode *PN = PHINode::Create(LPad->getType(), 0, "",
- ExitSucc->getFirstInsertionPt());
+ &*ExitSucc->getFirstInsertionPt());
for (pred_iterator I = pred_begin(ExitSucc), E = pred_end(ExitSucc);
I != E; ++I) {
for (unsigned i = 0, e = NewBlocks.size(); i != e; ++i)
for (BasicBlock::iterator I = NewBlocks[i]->begin(),
E = NewBlocks[i]->end(); I != E; ++I)
- RemapInstruction(I, VMap,RF_NoModuleLevelChanges|RF_IgnoreMissingEntries);
+ RemapInstruction(&*I, VMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingEntries);
// Rewrite the original preheader to select between versions of the loop.
BranchInst *OldBR = cast<BranchInst>(loopPreheader->getTerminator());
Succ->replaceAllUsesWith(Pred);
// Move all of the successor contents from Succ to Pred.
- Pred->getInstList().splice(BI, Succ->getInstList(), Succ->begin(),
- Succ->end());
+ Pred->getInstList().splice(BI->getIterator(), Succ->getInstList(),
+ Succ->begin(), Succ->end());
LPM->deleteSimpleAnalysisValue(BI, L);
BI->eraseFromParent();
RemoveFromWorklist(BI, Worklist);