diff --git a/llvm/lib/Analysis/DomTreeUpdater.cpp b/llvm/lib/Analysis/DomTreeUpdater.cpp --- a/llvm/lib/Analysis/DomTreeUpdater.cpp +++ b/llvm/lib/Analysis/DomTreeUpdater.cpp @@ -220,7 +220,7 @@ // 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 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -1056,7 +1056,7 @@ // 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 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -82,7 +82,7 @@ // 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 @@ 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 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -417,7 +417,7 @@ // 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 @@ // 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 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -284,7 +284,7 @@ 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 @@ } // 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 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -2930,7 +2930,7 @@ 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 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -807,7 +807,7 @@ 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 @@ // 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 @@ 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 @@ 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 @@ 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 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -673,7 +673,7 @@ 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 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -440,7 +440,7 @@ // 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 --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -559,7 +559,7 @@ 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 @@ 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 --- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -497,7 +497,7 @@ 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 --- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp +++ b/llvm/lib/Transforms/Utils/LowerInvoke.cpp @@ -66,7 +66,7 @@ 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 --- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp @@ -520,7 +520,7 @@ // 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 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -1057,7 +1057,7 @@ // 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 @@ 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 --- a/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -60,7 +60,7 @@ 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 @@ 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 --- a/llvm/tools/bugpoint-passes/TestPasses.cpp +++ b/llvm/tools/bugpoint-passes/TestPasses.cpp @@ -68,7 +68,7 @@ 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 --- a/llvm/tools/bugpoint/CrashDebugger.cpp +++ b/llvm/tools/bugpoint/CrashDebugger.cpp @@ -484,7 +484,7 @@ 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 --- a/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/llvm/tools/bugpoint/ExtractFunction.cpp @@ -105,7 +105,7 @@ 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;