diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2024-02-29 15:27:32 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2024-02-29 16:39:09 +0000 |
commit | 3fda50d3915b2163a54a37b602be7783a89dd808 (patch) | |
tree | db02ee8d9c1402e6023ce3ce8b7b771c0a6634ae /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 9491aecd235da9674150fe56bd0f29c3a22472c4 (diff) | |
download | llvm-3fda50d3915b2163a54a37b602be7783a89dd808.zip llvm-3fda50d3915b2163a54a37b602be7783a89dd808.tar.gz llvm-3fda50d3915b2163a54a37b602be7783a89dd808.tar.bz2 |
[NFC][RemoveDIs] Bulk update utilities to insert with iterators
As part of the RemoveDIs project we need LLVM to insert instructions using
iterators wherever possible, so that the iterators can carry a bit of
debug-info. This commit implements some of that by updating the contents of
llvm/lib/Transforms/Utils to always use iterator-versions of instruction
constructors.
There are two general flavours of update:
* Almost all call-sites just call getIterator on an instruction
* Several make use of an existing iterator (scenarios where the code is
actually significant for debug-info)
The underlying logic is that any call to getFirstInsertionPt or similar
APIs that identify the start of a block need to have that iterator passed
directly to the insertion function, without being converted to a bare
Instruction pointer along the way.
I've also switched DemotePHIToStack to take an optional iterator: it needs
to take an iterator, and having a no-insert-location behaviour appears to
be important. The constructors for ICmpInst and FCmpInst have been updated
too. They're the only instructions that take block _references_ rather than
pointers for certain calls, and a future patch is going to make use of
default-null block insertion locations.
All of this should be NFC.
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index f68fdb2..0e8e726 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -689,7 +689,7 @@ static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock, if (auto *CRI = dyn_cast<CleanupReturnInst>(BB->getTerminator())) { if (CRI->unwindsToCaller()) { auto *CleanupPad = CRI->getCleanupPad(); - CleanupReturnInst::Create(CleanupPad, UnwindDest, CRI); + CleanupReturnInst::Create(CleanupPad, UnwindDest, CRI->getIterator()); CRI->eraseFromParent(); UpdatePHINodes(&*BB); // Finding a cleanupret with an unwind destination would confuse @@ -737,7 +737,7 @@ static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock, auto *NewCatchSwitch = CatchSwitchInst::Create( CatchSwitch->getParentPad(), UnwindDest, CatchSwitch->getNumHandlers(), CatchSwitch->getName(), - CatchSwitch); + CatchSwitch->getIterator()); for (BasicBlock *PadBB : CatchSwitch->handlers()) NewCatchSwitch->addHandler(PadBB); // Propagate info for the old catchswitch over to the new one in @@ -972,7 +972,7 @@ static void PropagateOperandBundles(Function::iterator InlinedBB, I->getOperandBundlesAsDefs(OpBundles); OpBundles.emplace_back("funclet", CallSiteEHPad); - Instruction *NewInst = CallBase::Create(I, OpBundles, I); + Instruction *NewInst = CallBase::Create(I, OpBundles, I->getIterator()); NewInst->takeName(I); I->replaceAllUsesWith(NewInst); I->eraseFromParent(); @@ -2002,7 +2002,7 @@ inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind, Value *BundleArgs[] = {*objcarc::getAttachedARCFunction(&CB)}; OperandBundleDef OB("clang.arc.attachedcall", BundleArgs); auto *NewCall = CallBase::addOperandBundle( - CI, LLVMContext::OB_clang_arc_attachedcall, OB, CI); + CI, LLVMContext::OB_clang_arc_attachedcall, OB, CI->getIterator()); NewCall->copyMetadata(*CI); CI->replaceAllUsesWith(NewCall); CI->eraseFromParent(); @@ -2326,7 +2326,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, OpDefs.emplace_back("deopt", std::move(MergedDeoptArgs)); } - Instruction *NewI = CallBase::Create(ICS, OpDefs, ICS); + Instruction *NewI = CallBase::Create(ICS, OpDefs, ICS->getIterator()); // Note: the RAUW does the appropriate fixup in VMap, so we need to do // this even if the call returns void. @@ -2479,7 +2479,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, SmallVector<Value *, 6> Params(CI->args()); Params.append(VarArgsToForward.begin(), VarArgsToForward.end()); CallInst *NewCI = CallInst::Create( - CI->getFunctionType(), CI->getCalledOperand(), Params, "", CI); + CI->getFunctionType(), CI->getCalledOperand(), Params, "", CI->getIterator()); NewCI->setDebugLoc(CI->getDebugLoc()); NewCI->setAttributes(Attrs); NewCI->setCallingConv(CI->getCallingConv()); @@ -2776,7 +2776,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, // If the call site was an invoke instruction, add a branch to the normal // destination. if (InvokeInst *II = dyn_cast<InvokeInst>(&CB)) { - BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), &CB); + BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), CB.getIterator()); NewBr->setDebugLoc(Returns[0]->getDebugLoc()); } @@ -2813,7 +2813,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, if (InvokeInst *II = dyn_cast<InvokeInst>(&CB)) { // Add an unconditional branch to make this look like the CallInst case... - CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), &CB); + CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), CB.getIterator()); // Split the basic block. This guarantees that no PHI nodes will have to be // updated due to new incoming edges, and make the invoke case more @@ -2881,7 +2881,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, DebugLoc Loc; for (unsigned i = 0, e = Returns.size(); i != e; ++i) { ReturnInst *RI = Returns[i]; - BranchInst* BI = BranchInst::Create(AfterCallBB, RI); + BranchInst* BI = BranchInst::Create(AfterCallBB, RI->getIterator()); Loc = RI->getDebugLoc(); BI->setDebugLoc(Loc); RI->eraseFromParent(); |