This is part of a series of patches that aim at making Function::getBasicBlockList() private.
Differential Revision: https://reviews.llvm.org/D139984
// Move the block to the end of the function. Forward ref'd blocks are
// inserted wherever they happen to be referenced.
- F.getBasicBlockList().splice(F.end(), F.getBasicBlockList(), BB);
+ F.splice(F.end(), &F, BB->getIterator());
// Remove the block from forward ref sets.
if (Name.empty()) {
}
void BasicBlock::moveBefore(BasicBlock *MovePos) {
- MovePos->getParent()->getBasicBlockList().splice(
- MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator());
+ MovePos->getParent()->splice(MovePos->getIterator(), getParent(),
+ getIterator());
}
void BasicBlock::moveAfter(BasicBlock *MovePos) {
- MovePos->getParent()->getBasicBlockList().splice(
- ++MovePos->getIterator(), getParent()->getBasicBlockList(),
- getIterator());
+ MovePos->getParent()->splice(++MovePos->getIterator(), getParent(),
+ getIterator());
}
const Module *BasicBlock::getModule() const {
// Steal arguments and splice the body of Src into Dst.
Dst.stealArgumentListFrom(Src);
- Dst.getBasicBlockList().splice(Dst.end(), Src.getBasicBlockList());
+ Dst.splice(Dst.end(), &Src);
// Everything has been moved over. Remap it.
Mapper.scheduleRemapFunction(Dst);
// Move the body of the function into the new rewritten function, and replace
// this function with a stub.
- NewFunc->getBasicBlockList().splice(NewFunc->begin(), F.getBasicBlockList());
+ NewFunc->splice(NewFunc->begin(), &F);
for (std::pair<ReturnInst *, ReplacementVec> &Replacement : Replacements) {
ReturnInst *RI = Replacement.first;
// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
// function empty.
- NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList());
+ NF->splice(NF->begin(), F);
// We will collect all the new created allocas to promote them into registers
// after the following loop
// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
// function empty.
- NewFn->getBasicBlockList().splice(NewFn->begin(),
- OldFn->getBasicBlockList());
+ NewFn->splice(NewFn->begin(), OldFn);
// Fixup block addresses to reference new function.
SmallVector<BlockAddress *, 8u> BlockAddresses;
// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
// function empty.
- NF->getBasicBlockList().splice(NF->begin(), F.getBasicBlockList());
+ NF->splice(NF->begin(), &F);
// Loop over the argument list, transferring uses of the old arguments over to
// the new arguments, also transferring over the names as well. While we're
// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
// function empty.
- NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList());
+ NF->splice(NF->begin(), F);
// Loop over the argument list, transferring uses of the old arguments over to
// the new arguments, also transferring over the names as well.
// Place the cloned blocks right after the original blocks (right before the
// exit block of.)
if (ExitBlock)
- F.getBasicBlockList().splice(ExitBlock->getIterator(),
- F.getBasicBlockList(),
- NewBlocks[0]->getIterator(), F.end());
+ F.splice(ExitBlock->getIterator(), &F, NewBlocks[0]->getIterator(),
+ F.end());
// Update the cloned blocks/instructions to refer to themselves.
for (BasicBlock *NewBB : NewBlocks)
}
// Move them physically from the end of the block list.
- F->getBasicBlockList().splice(Before->getIterator(), F->getBasicBlockList(),
- NewPH);
- F->getBasicBlockList().splice(Before->getIterator(), F->getBasicBlockList(),
- NewLoop->getHeader()->getIterator(), F->end());
+ F->splice(Before->getIterator(), F, NewPH->getIterator());
+ F->splice(Before->getIterator(), F, NewLoop->getHeader()->getIterator(),
+ F->end());
return NewLoop;
}
// Now that the function is correct, make it a little bit nicer. In
// particular, move the basic blocks inserted from the end of the function
// into the space made by splitting the source basic block.
- Caller->getBasicBlockList().splice(AfterCallBB->getIterator(),
- Caller->getBasicBlockList(), FirstNewBlock,
- Caller->end());
+ Caller->splice(AfterCallBB->getIterator(), Caller, FirstNewBlock,
+ Caller->end());
// Handle all of the return instructions that we just cloned in, and eliminate
// any users of the original call/invoke instruction.
InsertBot = SplitBlock(InsertBot, InsertBot->getTerminator(), &DT, LI);
InsertBot->setName(Header->getName() + ".peel.next");
- F->getBasicBlockList().splice(InsertTop->getIterator(),
- F->getBasicBlockList(),
- NewBlocks[0]->getIterator(), F->end());
+ F->splice(InsertTop->getIterator(), F, NewBlocks[0]->getIterator(),
+ F->end());
}
// Now adjust the phi nodes in the loop header to get their initial values
// Move the new backedge block to right after the last backedge block.
Function::iterator InsertPos = ++BackedgeBlocks.back()->getIterator();
- F->getBasicBlockList().splice(InsertPos, F->getBasicBlockList(), BEBlock);
+ F->splice(InsertPos, F, BEBlock->getIterator());
// Now that the block has been inserted into the function, create PHI nodes in
// the backedge block which correspond to any PHI nodes in the header block.
updateLatchBranchWeightsForRemainderLoop(L, remainderLoop, Count);
// Insert the cloned blocks into the function.
- F->getBasicBlockList().splice(InsertBot->getIterator(),
- F->getBasicBlockList(),
- NewBlocks[0]->getIterator(),
- F->end());
+ F->splice(InsertBot->getIterator(), F, NewBlocks[0]->getIterator(), F->end());
// Now the loop blocks are cloned and the other exiting blocks from the
// remainder are connected to the original Loop's exit blocks. The remaining
D.replaceAllUsesWith(&E);
// Splice the body of the old function into the new one.
- E.getBasicBlockList().splice(E.begin(), D.getBasicBlockList());
+ E.splice(E.begin(), &D);
// And fix up the one argument.
D.arg_begin()->replaceAllUsesWith(&*E.arg_begin());
E.arg_begin()->takeName(&*D.arg_begin());