[llvm] dc89184 - [NFC] Cleanup: Replace Function::getBasicBlockList().splice() with Function::splice()
Vasileios Porpodas via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 15:34:57 PST 2022
Author: Vasileios Porpodas
Date: 2022-12-14T15:34:19-08:00
New Revision: dc891846b811cdf945e2cdacd9b227c2d0966e71
URL: https://github.com/llvm/llvm-project/commit/dc891846b811cdf945e2cdacd9b227c2d0966e71
DIFF: https://github.com/llvm/llvm-project/commit/dc891846b811cdf945e2cdacd9b227c2d0966e71.diff
LOG: [NFC] Cleanup: Replace Function::getBasicBlockList().splice() with Function::splice()
This is part of a series of patches that aim at making Function::getBasicBlockList() private.
Differential Revision: https://reviews.llvm.org/D139984
Added:
Modified:
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/lib/Transforms/Utils/LoopSimplify.cpp
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
llvm/unittests/Analysis/LazyCallGraphTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index ac84d25c98389..ba77b1f570fcd 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3326,7 +3326,7 @@ BasicBlock *LLParser::PerFunctionState::defineBB(const std::string &Name,
// 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()) {
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 06660ba249ef9..273a31fa90695 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -134,14 +134,13 @@ iplist<BasicBlock>::iterator BasicBlock::eraseFromParent() {
}
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 {
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 518f1a1622100..9e19220bbf433 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1120,7 +1120,7 @@ Error IRLinker::linkFunctionBody(Function &Dst, Function &Src) {
// 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);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
index 750253b09c611..3ff3546f4f92d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
@@ -332,7 +332,7 @@ bool AMDGPURewriteOutArguments::runOnFunction(Function &F) {
// 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;
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index beeda0c25c7bf..7dace08a8bf33 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -300,7 +300,7 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
// 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
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index e3dcfd95a68ee..21a4d4601eae7 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2686,8 +2686,7 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
// 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;
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 6b448b39f54b8..bf2c65a2402cb 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -222,7 +222,7 @@ bool DeadArgumentEliminationPass::deleteDeadVarargs(Function &F) {
// 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
@@ -996,7 +996,7 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
// 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.
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 068565a1ea005..9568c6605fd64 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -1790,9 +1790,8 @@ void CHR::cloneScopeBlocks(CHRScope *Scope,
// 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)
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index e76761fa1e22b..1e0400a409e9d 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -1013,10 +1013,9 @@ Loop *llvm::cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB,
}
// 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;
}
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index dfbcac71859ac..bde9b91f42682 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2834,9 +2834,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
// 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.
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index d370d6c7fa214..5b721cc42f746 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -998,9 +998,8 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI,
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
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
index c5d2fa7d82ae3..87a0e54e2704e 100644
--- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -392,7 +392,7 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader,
// 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.
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index f063438c7c41f..a6c32a11a5761 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -812,10 +812,7 @@ bool llvm::UnrollRuntimeLoopRemainder(
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
diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
index ee3c25423ddd8..921a10f592586 100644
--- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
@@ -2079,7 +2079,7 @@ TEST(LazyCallGraphTest, ReplaceNodeFunction) {
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());
More information about the llvm-commits
mailing list