diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -942,7 +942,7 @@ // Append the prepared cleanup prologue from above. llvm::BasicBlock *NormalExit = Builder.GetInsertBlock(); for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I) - InstsToAppend[I]->insertAt(NormalExit, NormalExit->end()); + InstsToAppend[I]->insertInto(NormalExit, NormalExit->end()); // Optimistically hope that any fixups will continue falling through. for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups(); diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -2861,7 +2861,7 @@ BasicBlock *pb = ...; auto *newInst = new Instruction(...); - newInst->insertAt(pb, pb->end()); // Appends newInst to pb + newInst->insertInto(pb, pb->end()); // Appends newInst to pb becomes: diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp --- a/llvm/examples/BrainF/BrainF.cpp +++ b/llvm/examples/BrainF/BrainF.cpp @@ -96,7 +96,7 @@ allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy); ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, nullptr, "arr"); - cast(ptr_arr)->insertAt(BB, BB->end()); + cast(ptr_arr)->insertInto(BB, BB->end()); //call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i1 0) { @@ -128,7 +128,7 @@ endbb = BasicBlock::Create(C, label, brainf_func); //call free(i8 *%arr) - CallInst::CreateFree(ptr_arr, endbb)->insertAt(endbb, endbb->end()); + CallInst::CreateFree(ptr_arr, endbb)->insertInto(endbb, endbb->end()); //ret void ReturnInst::Create(C, endbb); diff --git a/llvm/examples/ModuleMaker/ModuleMaker.cpp b/llvm/examples/ModuleMaker/ModuleMaker.cpp --- a/llvm/examples/ModuleMaker/ModuleMaker.cpp +++ b/llvm/examples/ModuleMaker/ModuleMaker.cpp @@ -55,10 +55,10 @@ "addresult"); // explicitly insert it into the basic block... - Add->insertAt(BB, BB->end()); + Add->insertInto(BB, BB->end()); // Create the return instruction and add it to the basic block - ReturnInst::Create(Context, Add)->insertAt(BB, BB->end()); + ReturnInst::Create(Context, Add)->insertInto(BB, BB->end()); // Output the bitcode file to stdout WriteBitcodeToFile(*M, outs()); diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -92,8 +92,8 @@ // These functions and classes need access to the instruction list. friend void Instruction::removeFromParent(); friend iplist::iterator Instruction::eraseFromParent(); - friend BasicBlock::iterator Instruction::insertAt(BasicBlock *BB, - BasicBlock::iterator It); + friend BasicBlock::iterator Instruction::insertInto(BasicBlock *BB, + BasicBlock::iterator It); friend class llvm::SymbolTableListTraits; friend class llvm::ilist_node_with_parent; @@ -378,7 +378,7 @@ /// Return the underlying instruction list container. /// This is deliberately private because we have implemented an adequate set /// of functions to modify the list, including BasicBlock::splice(), - /// BasicBlock::erase(), Instruction::insertAt() etc. + /// BasicBlock::erase(), Instruction::insertInto() etc. const InstListType &getInstList() const { return InstList; } InstListType &getInstList() { return InstList; } diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -66,7 +66,7 @@ BasicBlock *BB, BasicBlock::iterator InsertPt) const { if (BB) - I->insertAt(BB, InsertPt); + I->insertInto(BB, InsertPt); I->setName(Name); } }; diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -128,10 +128,10 @@ /// specified instruction. void insertAfter(Instruction *InsertPos); - /// Inserts an unlinked instruction into \p BB at position \p It and returns - /// the iterator of the inserted instruction. + /// Inserts an unlinked instruction into \p ParentBB at position \p It and + /// returns the iterator of the inserted instruction. SymbolTableList::iterator - insertAt(BasicBlock *BB, SymbolTableList::iterator It); + insertInto(BasicBlock *ParentBB, SymbolTableList::iterator It); /// Unlink this instruction from its current basic block and insert it into /// the basic block that MovePos lives in, right before MovePos. diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h --- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h +++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h @@ -397,7 +397,7 @@ assert(New && !New->getParent() && "New instruction already inserted into a basic block!"); BasicBlock *BB = Old.getParent(); - New->insertAt(BB, Old.getIterator()); // Insert inst + New->insertInto(BB, Old.getIterator()); // Insert inst Worklist.push(New); return New; } diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -6166,7 +6166,7 @@ llvm_unreachable("Unknown parseInstruction result!"); case InstError: return true; case InstNormal: - Inst->insertAt(BB, BB->end()); + Inst->insertInto(BB, BB->end()); // With a normal result, we check to see if the instruction is followed by // a comma and metadata. @@ -6175,7 +6175,7 @@ return true; break; case InstExtraComma: - Inst->insertAt(BB, BB->end()); + Inst->insertInto(BB, BB->end()); // If the instruction parser ate an extra comma at the end of it, it // *must* be followed by metadata. diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4836,7 +4836,7 @@ if (Temp) { InstructionList.push_back(Temp); assert(CurBB && "No current BB?"); - Temp->insertAt(CurBB, CurBB->end()); + Temp->insertInto(CurBB, CurBB->end()); } } else { auto CastOp = (Instruction::CastOps)Opc; @@ -6084,7 +6084,7 @@ // Before weak cmpxchgs existed, the instruction simply returned the // value loaded from memory, so bitcode files from that era will be // expecting the first component of a modern cmpxchg. - I->insertAt(CurBB, CurBB->end()); + I->insertInto(CurBB, CurBB->end()); I = ExtractValueInst::Create(I, 0); ResTypeID = CmpTypeID; } else { @@ -6408,7 +6408,7 @@ I->deleteValue(); return error("Operand bundles found with no consumer"); } - I->insertAt(CurBB, CurBB->end()); + I->insertInto(CurBB, CurBB->end()); // If this was a terminator instruction, move to the next block. if (I->isTerminator()) { diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -1212,8 +1212,8 @@ BranchInst *Goto = cast(IncomingBlock->getTerminator()); Goto->removeFromParent(); CatchRet->removeFromParent(); - CatchRet->insertAt(IncomingBlock, IncomingBlock->end()); - Goto->insertAt(NewBlock, NewBlock->end()); + CatchRet->insertInto(IncomingBlock, IncomingBlock->end()); + Goto->insertInto(NewBlock, NewBlock->end()); Goto->setSuccessor(0, PHIBlock); CatchRet->setSuccessor(NewBlock); // Update the color mapping for the newly split edge. diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -28,7 +28,7 @@ if (InsertBefore) { BasicBlock *BB = InsertBefore->getParent(); assert(BB && "Instruction to insert before is not in a basic block!"); - insertAt(BB, InsertBefore->getIterator()); + insertInto(BB, InsertBefore->getIterator()); } } @@ -38,7 +38,7 @@ // append this instruction into the basic block assert(InsertAtEnd && "Basic block to append to may not be NULL!"); - insertAt(InsertAtEnd, InsertAtEnd->end()); + insertInto(InsertAtEnd, InsertAtEnd->end()); } Instruction::~Instruction() { @@ -85,20 +85,21 @@ /// Insert an unlinked instruction into a basic block immediately before the /// specified instruction. void Instruction::insertBefore(Instruction *InsertPos) { - insertAt(InsertPos->getParent(), InsertPos->getIterator()); + insertInto(InsertPos->getParent(), InsertPos->getIterator()); } /// Insert an unlinked instruction into a basic block immediately after the /// specified instruction. void Instruction::insertAfter(Instruction *InsertPos) { - insertAt(InsertPos->getParent(), std::next(InsertPos->getIterator())); + insertInto(InsertPos->getParent(), std::next(InsertPos->getIterator())); } -BasicBlock::iterator Instruction::insertAt(BasicBlock *BB, - BasicBlock::iterator It) { +BasicBlock::iterator Instruction::insertInto(BasicBlock *ParentBB, + BasicBlock::iterator It) { assert(getParent() == nullptr && "Expected detached instruction"); - assert((It == BB->end() || It->getParent() == BB) && "It not in BB"); - return BB->getInstList().insert(It, this); + assert((It == ParentBB->end() || It->getParent() == ParentBB) && + "It not in ParentBB"); + return ParentBB->getInstList().insert(It, this); } /// Unlink this instruction from its current basic block and insert it into the diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -824,7 +824,7 @@ MCall = CallInst::Create(MallocFunc, AllocSize, OpB, "malloccall"); Result = MCall; if (Result->getType() != AllocPtrType) { - MCall->insertAt(InsertAtEnd, InsertAtEnd->end()); + MCall->insertInto(InsertAtEnd, InsertAtEnd->end()); // Create a cast instruction to convert to the right type... Result = new BitCastInst(MCall, AllocPtrType, Name); } @@ -2815,7 +2815,7 @@ const Twine &Name, BasicBlock *InsertAtEnd) { UnaryOperator *Res = Create(Op, S, Name); - Res->insertAt(InsertAtEnd, InsertAtEnd->end()); + Res->insertInto(InsertAtEnd, InsertAtEnd->end()); return Res; } @@ -2946,7 +2946,7 @@ const Twine &Name, BasicBlock *InsertAtEnd) { BinaryOperator *Res = Create(Op, S1, S2, Name); - Res->insertAt(InsertAtEnd, InsertAtEnd->end()); + Res->insertInto(InsertAtEnd, InsertAtEnd->end()); return Res; } diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp --- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -522,7 +522,7 @@ link(OpI, B, At); } - I->insertAt(B, At); + I->insertInto(B, At); } Value *Simplifier::Context::materialize(BasicBlock *B, diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp @@ -141,7 +141,7 @@ if (CastInst::isBitOrNoopPointerCastable(ArgType, ParamType, DL)) { Instruction *PtrCast = CastInst::CreateBitOrPointerCast(AI, ParamType, "cast"); - PtrCast->insertAt(BB, BB->end()); + PtrCast->insertInto(BB, BB->end()); Args.push_back(PtrCast); } else if (ArgType->isStructTy() || ParamType->isStructTy()) { LLVM_DEBUG(dbgs() << "createWrapper: struct param type in bitcast: " @@ -181,7 +181,7 @@ DL)) { Instruction *Cast = CastInst::CreateBitOrPointerCast(Call, RtnType, "cast"); - Cast->insertAt(BB, BB->end()); + Cast->insertInto(BB, BB->end()); ReturnInst::Create(M->getContext(), Cast, BB); } else if (RtnType->isStructTy() || ExpectedRtnType->isStructTy()) { LLVM_DEBUG(dbgs() << "createWrapper: struct return type in bitcast: " diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -1873,7 +1873,7 @@ StoreInst *NewI = cast(I->clone()); NewI->setDebugLoc(DebugLoc()); BasicBlock *OutputBB = VBBIt->second; - NewI->insertAt(OutputBB, OutputBB->end()); + NewI->insertInto(OutputBB, OutputBB->end()); LLVM_DEBUG(dbgs() << "Move store for instruction " << *I << " to " << *OutputBB << "\n"); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -391,7 +391,7 @@ assert(New && !New->getParent() && "New instruction already inserted into a basic block!"); BasicBlock *BB = Old.getParent(); - New->insertAt(BB, Old.getIterator()); // Insert inst + New->insertInto(BB, Old.getIterator()); // Insert inst Worklist.add(New); return New; } diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2213,7 +2213,7 @@ if (Instruction *I = visitBitCast(*BCI)) { if (I != BCI) { I->takeName(BCI); - I->insertAt(BCI->getParent(), BCI->getIterator()); + I->insertInto(BCI->getParent(), BCI->getIterator()); replaceInstUsesWith(*BCI, I); } return &GEP; @@ -2419,7 +2419,7 @@ NewGEP->setOperand(DI, NewPN); } - NewGEP->insertAt(GEP.getParent(), GEP.getParent()->getFirstInsertionPt()); + NewGEP->insertInto(GEP.getParent(), GEP.getParent()->getFirstInsertionPt()); return replaceOperand(GEP, 0, NewGEP); } @@ -4332,7 +4332,7 @@ InsertPos = InstParent->getFirstNonPHI()->getIterator(); } - Result->insertAt(InstParent, InsertPos); + Result->insertInto(InstParent, InsertPos); // Push the new instruction and any users onto the worklist. Worklist.pushUsersToWorkList(*Result); diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -1837,7 +1837,7 @@ BranchInst *NewBR = BranchInst::Create(NewEntryBlock, cast(VMap[NewEntryBlock]), ConstantInt::getTrue(F.getContext())); - NewBR->insertAt(PreEntryBlock, PreEntryBlock->end()); + NewBR->insertInto(PreEntryBlock, PreEntryBlock->end()); assert(NewEntryBlock->getSinglePredecessor() == EntryBlock && "NewEntryBlock's only pred must be EntryBlock"); return NewBR; diff --git a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp @@ -422,7 +422,7 @@ assert(SizeType && "Expected integer type size argument."); ConstantInt *CaseSizeId = ConstantInt::get(SizeType, SizeId); NewMO.setLength(CaseSizeId); - NewMO.I->insertAt(CaseBB, CaseBB->end()); + NewMO.I->insertInto(CaseBB, CaseBB->end()); IRBuilder<> IRBCase(CaseBB); IRBCase.CreateBr(MergeBB); SI->addCase(CaseSizeId, CaseBB); diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -2107,7 +2107,7 @@ for (; BI != BE; ++BI) { Instruction *New = BI->clone(); New->setName(BI->getName()); - New->insertAt(NewBB, NewBB->end()); + New->insertInto(NewBB, NewBB->end()); ValueMapping[&*BI] = New; adaptNoAliasScopes(New, ClonedScopes, Context); @@ -2700,7 +2700,7 @@ if (New) { // Otherwise, insert the new instruction into the block. New->setName(BI->getName()); - New->insertAt(PredBB, OldPredBranch->getIterator()); + New->insertInto(PredBB, OldPredBranch->getIterator()); // Update Dominance from simplified New instruction operands. for (unsigned i = 0, e = New->getNumOperands(); i != e; ++i) if (BasicBlock *SuccBB = dyn_cast(New->getOperand(i))) @@ -2754,7 +2754,7 @@ BB->getParent(), BB); // Move the unconditional branch to NewBB. PredTerm->removeFromParent(); - PredTerm->insertAt(NewBB, NewBB->end()); + PredTerm->insertInto(NewBB, NewBB->end()); // Create a conditional branch and update PHI nodes. auto *BI = BranchInst::Create(NewBB, BB, SI->getCondition(), Pred); BI->applyMergedLocation(PredTerm->getDebugLoc(), SI->getDebugLoc()); diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1430,7 +1430,7 @@ New = I.clone(); } - New->insertAt(&ExitBlock, ExitBlock.getFirstInsertionPt()); + New->insertInto(&ExitBlock, ExitBlock.getFirstInsertionPt()); if (!I.getName().empty()) New->setName(I.getName() + ".le"); diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2535,7 +2535,7 @@ ICmpInst *OldCond = Cond; Cond = cast(Cond->clone()); Cond->setName(L->getHeader()->getName() + ".termcond"); - Cond->insertAt(ExitingBlock, TermBr->getIterator()); + Cond->insertInto(ExitingBlock, TermBr->getIterator()); // Clone the IVUse, as the old use still exists! CondUse = &IU.AddUser(Cond, CondUse->getOperandValToReplace()); diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -255,7 +255,7 @@ for (auto *Val : reverse(ToDuplicate)) { Instruction *Inst = cast(Val); Instruction *NewInst = Inst->clone(); - NewInst->insertAt(&BB, BB.end()); + NewInst->insertInto(&BB, BB.end()); RemapInstruction(NewInst, VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); VMap[Val] = NewInst; @@ -585,7 +585,7 @@ if (MSSAU) { // Temporarily clone the terminator, to make MSSA update cheaper by // separating "insert edge" updates from "remove edge" ones. - BI.clone()->insertAt(ParentBB, ParentBB->end()); + BI.clone()->insertInto(ParentBB, ParentBB->end()); } else { // Create a new unconditional branch that will continue the loop as a new // terminator. @@ -2255,7 +2255,7 @@ // Keep a clone of the terminator for MSSA updates. Instruction *NewTI = TI.clone(); - NewTI->insertAt(ParentBB, ParentBB->end()); + NewTI->insertInto(ParentBB, ParentBB->end()); // First wire up the moved terminator to the preheaders. if (BI) { diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -108,12 +108,12 @@ std::get<1>(I) = PHINode::Create(std::get<0>(I)->getType(), /*NumReservedValues=*/BBs.size(), CanonicalBB->getName() + ".op"); - std::get<1>(I)->insertAt(CanonicalBB, CanonicalBB->end()); + std::get<1>(I)->insertInto(CanonicalBB, CanonicalBB->end()); } // Make it so that this canonical block actually has the right // terminator. CanonicalTerm = Term->clone(); - CanonicalTerm->insertAt(CanonicalBB, CanonicalBB->end()); + CanonicalTerm->insertInto(CanonicalBB, CanonicalBB->end()); // If the canonical terminator has operands, rewrite it to take PHI's. for (auto I : zip(NewOps, CanonicalTerm->operands())) std::get<1>(I) = std::get<0>(I); diff --git a/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp b/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp --- a/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp +++ b/llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp @@ -234,7 +234,7 @@ BasicBlock::iterator Iter = findInsertPos(Fn, GV, PosBB); Type *Ty = GV->getType(); auto *CastInst = new BitCastInst(GV, Ty, "tls_bitcast"); - CastInst->insertAt(PosBB, Iter); + CastInst->insertInto(PosBB, Iter); return CastInst; } 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 @@ -565,7 +565,7 @@ I->setDebugLoc(BI->getDebugLoc()); // Insert the new instruction into the basic block... - BasicBlock::iterator New = I->insertAt(BB, BI); + BasicBlock::iterator New = I->insertInto(BB, BI); // Replace all uses of the old instruction, and delete it. ReplaceInstWithValue(BI, I); @@ -1343,12 +1343,12 @@ LandingPadInst *LPad = OrigBB->getLandingPadInst(); Instruction *Clone1 = LPad->clone(); Clone1->setName(Twine("lpad") + Suffix1); - Clone1->insertAt(NewBB1, NewBB1->getFirstInsertionPt()); + Clone1->insertInto(NewBB1, NewBB1->getFirstInsertionPt()); if (NewBB2) { Instruction *Clone2 = LPad->clone(); Clone2->setName(Twine("lpad") + Suffix2); - Clone2->insertAt(NewBB2, NewBB2->getFirstInsertionPt()); + Clone2->insertInto(NewBB2, NewBB2->getFirstInsertionPt()); // Create a PHI node for the two cloned landingpad instructions only // if the original landingpad instruction has some uses. @@ -1399,7 +1399,7 @@ Instruction *UncondBranch = Pred->getTerminator(); // Clone the return and add it to the end of the predecessor. Instruction *NewRet = RI->clone(); - NewRet->insertAt(Pred, Pred->end()); + NewRet->insertInto(Pred, Pred->end()); // If the return instruction returns a value, and if the value was a // PHI node in "BB", propagate the right value into the return. @@ -1411,7 +1411,7 @@ // return instruction. V = BCI->getOperand(0); NewBC = BCI->clone(); - NewBC->insertAt(Pred, NewRet->getIterator()); + NewBC->insertInto(Pred, NewRet->getIterator()); Op = NewBC; } @@ -1421,9 +1421,9 @@ NewEV = EVI->clone(); if (NewBC) { NewBC->setOperand(0, NewEV); - NewEV->insertAt(Pred, NewBC->getIterator()); + NewEV->insertInto(Pred, NewBC->getIterator()); } else { - NewEV->insertAt(Pred, NewRet->getIterator()); + NewEV->insertInto(Pred, NewRet->getIterator()); Op = NewEV; } } diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -58,7 +58,7 @@ Instruction *NewInst = I.clone(); if (I.hasName()) NewInst->setName(I.getName() + NameSuffix); - NewInst->insertAt(NewBB, NewBB->end()); + NewInst->insertInto(NewBB, NewBB->end()); VMap[&I] = NewInst; // Add instruction map to value. if (isa(I) && !I.isDebugOrPseudoInst()) { @@ -521,7 +521,7 @@ if (II->hasName()) NewInst->setName(II->getName() + NameSuffix); VMap[&*II] = NewInst; // Add instruction map to value. - NewInst->insertAt(NewBB, NewBB->end()); + NewInst->insertInto(NewBB, NewBB->end()); if (isa(II) && !II->isDebugOrPseudoInst()) { hasCalls = true; hasMemProfMetadata |= II->hasMetadata(LLVMContext::MD_memprof); @@ -583,7 +583,7 @@ Instruction *NewInst = OldTI->clone(); if (OldTI->hasName()) NewInst->setName(OldTI->getName() + NameSuffix); - NewInst->insertAt(NewBB, NewBB->end()); + NewInst->insertInto(NewBB, NewBB->end()); VMap[OldTI] = NewInst; // Add instruction map to value. if (CodeInfo) { diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -1208,7 +1208,7 @@ Idx[1] = ConstantInt::get(Type::getInt32Ty(Context), i); GetElementPtrInst *GEP = GetElementPtrInst::Create( StructArgTy, Struct, Idx, "gep_" + StructValues[i]->getName()); - GEP->insertAt(codeReplacer, codeReplacer->end()); + GEP->insertInto(codeReplacer, codeReplacer->end()); new StoreInst(StructValues[i], GEP, codeReplacer); NumAggregatedInputs++; } @@ -1226,7 +1226,7 @@ if (auto DL = newFunction->getEntryBlock().getTerminator()->getDebugLoc()) call->setDebugLoc(DL); } - call->insertAt(codeReplacer, codeReplacer->end()); + call->insertInto(codeReplacer, codeReplacer->end()); // Set swifterror parameter attributes. for (unsigned SwiftErrArgNo : SwiftErrorArgs) { @@ -1246,7 +1246,7 @@ Idx[1] = ConstantInt::get(Type::getInt32Ty(Context), aggIdx); GetElementPtrInst *GEP = GetElementPtrInst::Create( StructArgTy, Struct, Idx, "gep_reload_" + outputs[i]->getName()); - GEP->insertAt(codeReplacer, codeReplacer->end()); + GEP->insertInto(codeReplacer, codeReplacer->end()); Output = GEP; ++aggIdx; } else { @@ -1735,7 +1735,7 @@ }); }); } - BranchI->insertAt(newFuncRoot, newFuncRoot->end()); + BranchI->insertInto(newFuncRoot, newFuncRoot->end()); ValueSet SinkingCands, HoistingCands; BasicBlock *CommonExit = nullptr; diff --git a/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp b/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp --- a/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp +++ b/llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp @@ -496,7 +496,7 @@ assert(SuccBB && "The split block should have a single successor"); SuccBB->setName("cdce.end"); CI->removeFromParent(); - CI->insertAt(CallBB, CallBB->getFirstInsertionPt()); + CI->insertInto(CallBB, CallBB->getFirstInsertionPt()); LLVM_DEBUG(dbgs() << "== Basic Block After =="); LLVM_DEBUG(dbgs() << *CallBB->getSinglePredecessor() << *CallBB << *CallBB->getSingleSuccessor() << "\n"); 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 @@ -301,7 +301,7 @@ NewNode, OrigBlock, Default, UnreachableRanges); F->insert(++OrigBlock->getIterator(), NewNode); - Comp->insertAt(NewNode, NewNode->end()); + Comp->insertInto(NewNode, NewNode->end()); BranchInst::Create(LBranch, RBranch, Comp, NewNode); return NewNode; diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1128,7 +1128,7 @@ NewBonusInst->dropUndefImplyingAttrsAndUnknownMetadata( LLVMContext::MD_annotation); - NewBonusInst->insertAt(PredBlock, PTI->getIterator()); + NewBonusInst->insertInto(PredBlock, PTI->getIterator()); NewBonusInst->takeName(&BonusInst); BonusInst.setName(NewBonusInst->getName() + ".old"); @@ -1693,7 +1693,7 @@ // Okay, it is safe to hoist the terminator. Instruction *NT = I1->clone(); - NT->insertAt(BIParent, BI->getIterator()); + NT->insertInto(BIParent, BI->getIterator()); if (!NT->getType()->isVoidTy()) { I1->replaceAllUsesWith(NT); I2->replaceAllUsesWith(NT); @@ -2497,7 +2497,7 @@ auto *MergedInvoke = cast(II0->clone()); // NOTE: all invokes have the same attributes, so no handling needed. - MergedInvoke->insertAt(MergedInvokeBB, MergedInvokeBB->end()); + MergedInvoke->insertInto(MergedInvokeBB, MergedInvokeBB->end()); if (!HasNormalDest) { // This set does not have a normal destination, @@ -3244,7 +3244,7 @@ } if (N) { // Insert the new instruction into its new home. - N->insertAt(EdgeBB, InsertPt); + N->insertInto(EdgeBB, InsertPt); // Register the new instruction with the assumption cache if necessary. if (auto *Assume = dyn_cast(N)) 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 @@ -90,7 +90,7 @@ // If the function doesn't return void... add a PHI node to the block... PN = PHINode::Create(F.getReturnType(), ReturningBlocks.size(), "UnifiedRetVal"); - PN->insertAt(NewRetBlock, NewRetBlock->end()); + PN->insertInto(NewRetBlock, NewRetBlock->end()); ReturnInst::Create(F.getContext(), PN, NewRetBlock); } diff --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp --- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp +++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp @@ -429,7 +429,7 @@ BasicBlock *BB = BasicBlock::Create(C); BB->insertInto(F); Instruction *Ret = ReturnInst::Create(C); - Ret->insertAt(BB, BB->begin()); + Ret->insertInto(BB, BB->begin()); Function *FnAssume = Intrinsic::getDeclaration(Mod.get(), Intrinsic::assume); std::vector ShuffledArgs; diff --git a/llvm/unittests/Analysis/MemorySSATest.cpp b/llvm/unittests/Analysis/MemorySSATest.cpp --- a/llvm/unittests/Analysis/MemorySSATest.cpp +++ b/llvm/unittests/Analysis/MemorySSATest.cpp @@ -282,7 +282,7 @@ // - remove from original block LoadInst *LoadInstClone = cast(LoadInst1->clone()); - LoadInstClone->insertAt(Merge, Merge->begin()); + LoadInstClone->insertInto(Merge, Merge->begin()); MemoryAccess * NewLoadAccess = Updater.createMemoryAccessInBB(LoadInstClone, nullptr, LoadInstClone->getParent(), diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -1624,7 +1624,7 @@ EXPECT_EQ(Known.Zero.getZExtValue(), 0u); BasicBlock *BB = BasicBlock::Create(Context); - CI->insertAt(BB, BB->end()); + CI->insertInto(BB, BB->end()); Known = computeKnownBits(CI, M.getDataLayout(), /* Depth */ 0); // There is no parent function so we cannot look up the vscale_range // attribute to determine the number of bits. diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -1695,7 +1695,7 @@ BasicBlock *BB = &*F->begin(); Instruction *Ret = &*BB->begin(); Instruction *I = BinaryOperator::CreateAdd(ArgA, ArgB); - auto It = I->insertAt(BB, BB->begin()); + auto It = I->insertInto(BB, BB->begin()); EXPECT_EQ(&*It, I); EXPECT_EQ(I->getNextNode(), Ret); } @@ -1714,7 +1714,7 @@ BasicBlock *BB = &*F->begin(); Instruction *Ret = &*BB->begin(); Instruction *I = BinaryOperator::CreateAdd(ArgA, ArgB); - auto It = I->insertAt(BB, BB->end()); + auto It = I->insertInto(BB, BB->end()); EXPECT_EQ(&*It, I); EXPECT_EQ(Ret->getNextNode(), I); }