From af4e856fa71c6b5086aeda79bfcd954e98cef591 Mon Sep 17 00:00:00 2001 From: Vasileios Porpodas Date: Wed, 23 Nov 2022 14:53:00 -0800 Subject: [PATCH] [NFC] Replaced BB->getInstList().{erase(),pop_front(),pop_back()} with eraseFromParent(). Differential Revision: https://reviews.llvm.org/D138617 --- llvm/lib/Analysis/DomTreeUpdater.cpp | 2 +- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp | 2 +- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 6 +++--- llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 4 ++-- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 4 ++-- llvm/lib/Transforms/Utils/InlineFunction.cpp | 2 +- llvm/lib/Transforms/Utils/Local.cpp | 10 +++++----- llvm/lib/Transforms/Utils/LoopPeel.cpp | 2 +- llvm/lib/Transforms/Utils/LoopSimplify.cpp | 2 +- llvm/lib/Transforms/Utils/LoopUnroll.cpp | 4 ++-- llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp | 2 +- llvm/lib/Transforms/Utils/LowerInvoke.cpp | 2 +- llvm/lib/Transforms/Utils/LowerSwitch.cpp | 2 +- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 4 ++-- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 4 ++-- llvm/tools/bugpoint-passes/TestPasses.cpp | 2 +- llvm/tools/bugpoint/CrashDebugger.cpp | 2 +- llvm/tools/bugpoint/ExtractFunction.cpp | 2 +- 18 files changed, 29 insertions(+), 29 deletions(-) diff --git a/llvm/lib/Analysis/DomTreeUpdater.cpp b/llvm/lib/Analysis/DomTreeUpdater.cpp index d21948f..0a16fc9 100644 --- a/llvm/lib/Analysis/DomTreeUpdater.cpp +++ b/llvm/lib/Analysis/DomTreeUpdater.cpp @@ -220,7 +220,7 @@ void DomTreeUpdater::validateDeleteBB(BasicBlock *DelBB) { // Replace used instructions with an arbitrary value (poison). if (!I.use_empty()) I.replaceAllUsesWith(PoisonValue::get(I.getType())); - DelBB->getInstList().pop_back(); + DelBB->back().eraseFromParent(); } // Make sure DelBB has a valid terminator instruction. As long as DelBB is a // Child of Function F it must contain valid IR. diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index 5cf6591..6b448b3 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -1056,7 +1056,7 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) { // value (possibly 0 if we became void). auto *NewRet = ReturnInst::Create(F->getContext(), RetVal, RI); NewRet->setDebugLoc(RI->getDebugLoc()); - BB.getInstList().erase(RI); + RI->eraseFromParent(); } // Clone metadata from the old function, including debug info descriptor. diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index cf783ca..65840a0 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -82,7 +82,7 @@ void llvm::detachDeadBlocks( // eventually be removed (they are themselves dead). if (!I.use_empty()) I.replaceAllUsesWith(PoisonValue::get(I.getType())); - BB->getInstList().pop_back(); + BB->back().eraseFromParent(); } new UnreachableInst(BB->getContext(), BB); assert(BB->size() == 1 && @@ -279,13 +279,13 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU, if (PredecessorWithTwoSuccessors) { // Delete the unconditional branch from BB. - BB->getInstList().pop_back(); + BB->back().eraseFromParent(); // Update branch in the predecessor. PredBB_BI->setSuccessor(FallThruPath, NewSucc); } else { // Delete the unconditional branch from the predecessor. - PredBB->getInstList().pop_back(); + PredBB->back().eraseFromParent(); // Move terminator instruction. PredBB->getInstList().splice(PredBB->end(), BB->getInstList()); diff --git a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index 833d042..bd7a7f1 100644 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -417,7 +417,7 @@ Optional FastDivInsertionTask::insertFastDivAndRem() { // Split the basic block before the div/rem. BasicBlock *SuccessorBB = MainBB->splitBasicBlock(SlowDivOrRem); // Remove the unconditional branch from MainBB to SuccessorBB. - MainBB->getInstList().back().eraseFromParent(); + MainBB->back().eraseFromParent(); QuotRemWithBB Long; Long.BB = MainBB; Long.Quotient = ConstantInt::get(getSlowType(), 0); @@ -434,7 +434,7 @@ Optional FastDivInsertionTask::insertFastDivAndRem() { // Split the basic block before the div/rem. BasicBlock *SuccessorBB = MainBB->splitBasicBlock(SlowDivOrRem); // Remove the unconditional branch from MainBB to SuccessorBB. - MainBB->getInstList().back().eraseFromParent(); + MainBB->back().eraseFromParent(); QuotRemWithBB Fast = createFastBB(SuccessorBB); QuotRemWithBB Slow = createSlowBB(SuccessorBB); QuotRemPair Result = createDivRemPhiNodes(Fast, Slow, SuccessorBB); diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 9d60f8b..e543ca1 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -284,7 +284,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder) { do { CB = PBI->getSuccessor(1 - Idx); // Delete the conditional branch. - FirstCondBlock->getInstList().pop_back(); + FirstCondBlock->back().eraseFromParent(); FirstCondBlock->getInstList() .splice(FirstCondBlock->end(), CB->getInstList()); PBI = cast(FirstCondBlock->getTerminator()); @@ -480,7 +480,7 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { } // Merge \param SecondEntryBlock into \param FirstEntryBlock. - FirstEntryBlock->getInstList().pop_back(); + FirstEntryBlock->back().eraseFromParent(); FirstEntryBlock->getInstList() .splice(FirstEntryBlock->end(), SecondEntryBlock->getInstList()); BranchInst *PBI = cast(FirstEntryBlock->getTerminator()); diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 5c9511c..9ae6741 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -2930,7 +2930,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, OrigBB->getInstList().splice(Br->getIterator(), CalleeEntry->getInstList()); // Remove the unconditional branch. - OrigBB->getInstList().erase(Br); + Br->eraseFromParent(); // Now we can remove the CalleeEntry block, which is now empty. Caller->getBasicBlockList().erase(CalleeEntry); diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 8f996e9..2e0b4b0 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -807,7 +807,7 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, DestBB->moveAfter(PredBB); if (DTU) { - assert(PredBB->getInstList().size() == 1 && + assert(PredBB->size() == 1 && isa(PredBB->getTerminator()) && "The successor list of PredBB isn't empty before " "applying corresponding DTU updates."); @@ -1228,7 +1228,7 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB, // Clear the successor list of BB to match updates applying to DTU later. if (BB->getTerminator()) - BB->getInstList().pop_back(); + BB->back().eraseFromParent(); new UnreachableInst(BB->getContext(), BB); assert(succ_empty(BB) && "The successor list of BB isn't empty before " "applying corresponding DTU updates."); @@ -2238,7 +2238,7 @@ unsigned llvm::changeToUnreachable(Instruction *I, bool PreserveLCSSA, while (BBI != BBE) { if (!BBI->use_empty()) BBI->replaceAllUsesWith(PoisonValue::get(BBI->getType())); - BB->getInstList().erase(BBI++); + BBI++->eraseFromParent(); ++NumInstrsRemoved; } if (DTU) { @@ -2308,7 +2308,7 @@ BasicBlock *llvm::changeToInvokeAndSplitBasicBlock(CallInst *CI, CI->getName() + ".noexc"); // Delete the unconditional branch inserted by SplitBlock - BB->getInstList().pop_back(); + BB->back().eraseFromParent(); // Create the new invoke instruction. SmallVector InvokeArgs(CI->args()); @@ -2336,7 +2336,7 @@ BasicBlock *llvm::changeToInvokeAndSplitBasicBlock(CallInst *CI, CI->replaceAllUsesWith(II); // Delete the original call - Split->getInstList().pop_front(); + Split->front().eraseFromParent(); return Split; } diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp index b7e3eb2..c61feff 100644 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -673,7 +673,7 @@ static void cloneLoopBlocks( else VMap[&*I] = LatchVal; } - cast(VMap[Header])->getInstList().erase(NewPHI); + NewPHI->eraseFromParent(); } // Fix up the outgoing values - we need to add a value for the iteration diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 8943b4b..c5d2fa7 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -440,7 +440,7 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader, // eliminate the PHI Node. if (HasUniqueIncomingValue) { NewPN->replaceAllUsesWith(UniqueValue); - BEBlock->getInstList().erase(NewPN); + NewPN->eraseFromParent(); } } diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp index fd874db..bc3a30a 100644 --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -559,7 +559,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI, if (It > 1 && L->contains(InValI)) InVal = LastValueMap[InValI]; VMap[OrigPHI] = InVal; - New->getInstList().erase(NewPHI); + NewPHI->eraseFromParent(); } // Update our running map of newest clones @@ -633,7 +633,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI, for (PHINode *PN : OrigPHINode) { if (CompletelyUnroll) { PN->replaceAllUsesWith(PN->getIncomingValueForBlock(Preheader)); - Header->getInstList().erase(PN); + PN->eraseFromParent(); } else if (ULO.Count > 1) { Value *InVal = PN->removeIncomingValue(LatchBlock, false); // If this value was defined in the loop, take the value defined by the diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp index 96485d1..e274b0f 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -497,7 +497,7 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount, if (CompletelyUnroll) { while (PHINode *Phi = dyn_cast(ForeBlocksFirst[0]->begin())) { Phi->replaceAllUsesWith(Phi->getIncomingValueForBlock(Preheader)); - Phi->getParent()->getInstList().erase(Phi); + Phi->eraseFromParent(); } } else { // Update the PHI values to point to the last aft block diff --git a/llvm/lib/Transforms/Utils/LowerInvoke.cpp b/llvm/lib/Transforms/Utils/LowerInvoke.cpp index 59cfa41..6d78885 100644 --- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp +++ b/llvm/lib/Transforms/Utils/LowerInvoke.cpp @@ -66,7 +66,7 @@ static bool runImpl(Function &F) { II->getUnwindDest()->removePredecessor(&BB); // Remove the invoke instruction now. - BB.getInstList().erase(II); + II->eraseFromParent(); ++NumInvokes; Changed = true; diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp index 44aeb26..a0019d0 100644 --- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp @@ -520,7 +520,7 @@ void ProcessSwitchInst(SwitchInst *SI, // We are now done with the switch instruction, delete it. BasicBlock *OldDefault = SI->getDefaultDest(); - OrigBlock->getInstList().erase(SI); + SI->eraseFromParent(); // If the Default block has no more predecessors just add it to DeleteList. if (pred_empty(OldDefault)) diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 195b1bc..f5a7645 100644 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -1057,7 +1057,7 @@ NextIteration: // Anything using the load now uses the current value. LI->replaceAllUsesWith(V); - BB->getInstList().erase(LI); + LI->eraseFromParent(); } else if (StoreInst *SI = dyn_cast(I)) { // Delete this instruction and mark the name as the current holder of the // value @@ -1079,7 +1079,7 @@ NextIteration: for (DbgVariableIntrinsic *DII : AllocaDbgUsers[ai->second]) if (DII->isAddressOfVariable()) ConvertDebugDeclareToDebugValue(DII, SI, DIB); - BB->getInstList().erase(SI); + SI->eraseFromParent(); } } diff --git a/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 3631733..596056b 100644 --- a/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -60,7 +60,7 @@ bool unifyUnreachableBlocks(Function &F) { new UnreachableInst(F.getContext(), UnreachableBlock); for (BasicBlock *BB : UnreachableBlocks) { - BB->getInstList().pop_back(); // Remove the unreachable inst. + BB->back().eraseFromParent(); // Remove the unreachable inst. BranchInst::Create(UnreachableBlock, BB); } @@ -102,7 +102,7 @@ bool unifyReturnBlocks(Function &F) { if (PN) PN->addIncoming(BB->getTerminator()->getOperand(0), BB); - BB->getInstList().pop_back(); // Remove the return insn + BB->back().eraseFromParent(); // Remove the return insn BranchInst::Create(NewRetBlock, BB); } diff --git a/llvm/tools/bugpoint-passes/TestPasses.cpp b/llvm/tools/bugpoint-passes/TestPasses.cpp index 1e66953..aad1377 100644 --- a/llvm/tools/bugpoint-passes/TestPasses.cpp +++ b/llvm/tools/bugpoint-passes/TestPasses.cpp @@ -68,7 +68,7 @@ private: if (CallInst *CI = dyn_cast(I)) { if (!CI->use_empty()) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); - CI->getParent()->getInstList().erase(CI); + CI->eraseFromParent(); break; } return false; diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp index 2724d8c..c90e1af 100644 --- a/llvm/tools/bugpoint/CrashDebugger.cpp +++ b/llvm/tools/bugpoint/CrashDebugger.cpp @@ -484,7 +484,7 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector &BBs) { BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType())); // Replace the old terminator instruction. - BB.getInstList().pop_back(); + BB.back().eraseFromParent(); new UnreachableInst(BB.getContext(), &BB); } } diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp index 7a75cb9..5047aa3 100644 --- a/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/llvm/tools/bugpoint/ExtractFunction.cpp @@ -105,7 +105,7 @@ BugDriver::deleteInstructionFromProgram(const Instruction *I, TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType())); // Remove the instruction from the program. - TheInst->getParent()->getInstList().erase(TheInst); + TheInst->eraseFromParent(); // Spiff up the output a little bit. std::vector Passes; -- 2.7.4