diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2020-07-07 01:16:36 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2020-07-07 01:16:36 +0300 |
commit | 69dca6efc60a40a939ca5025a8c716e891c2847a (patch) | |
tree | 8130a56868165b246d51128c2aa33b9262cbbbcf /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | c143900a0851b2c7b7d52e4825c7f073b3474cf6 (diff) | |
download | llvm-69dca6efc60a40a939ca5025a8c716e891c2847a.zip llvm-69dca6efc60a40a939ca5025a8c716e891c2847a.tar.gz llvm-69dca6efc60a40a939ca5025a8c716e891c2847a.tar.bz2 |
[NFCI][IR] Introduce CallBase::Create() wrapper
Summary:
It is reasonably common to want to clone some call with different bundles.
Let's actually provide an interface to do that.
Reviewers: chandlerc, jdoerfert, dblaikie, nickdesaulniers
Reviewed By: nickdesaulniers
Subscribers: llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83248
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 203e812..b0b7ca4 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1864,13 +1864,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, OpDefs.emplace_back("deopt", std::move(MergedDeoptArgs)); } - Instruction *NewI = nullptr; - if (isa<CallInst>(ICS)) - NewI = CallInst::Create(cast<CallInst>(ICS), OpDefs, ICS); - else if (isa<CallBrInst>(ICS)) - NewI = CallBrInst::Create(cast<CallBrInst>(ICS), OpDefs, ICS); - else - NewI = InvokeInst::Create(cast<InvokeInst>(ICS), OpDefs, ICS); + Instruction *NewI = CallBase::Create(ICS, OpDefs, ICS); // Note: the RAUW does the appropriate fixup in VMap, so we need to do // this even if the call returns void. @@ -2166,13 +2160,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, I->getOperandBundlesAsDefs(OpBundles); OpBundles.emplace_back("funclet", CallSiteEHPad); - Instruction *NewInst; - if (auto *CallI = dyn_cast<CallInst>(I)) - NewInst = CallInst::Create(CallI, OpBundles, CallI); - else if (auto *CallBrI = dyn_cast<CallBrInst>(I)) - NewInst = CallBrInst::Create(CallBrI, OpBundles, CallBrI); - else - NewInst = InvokeInst::Create(cast<InvokeInst>(I), OpBundles, I); + Instruction *NewInst = CallBase::Create(I, OpBundles, I); NewInst->takeName(I); I->replaceAllUsesWith(NewInst); I->eraseFromParent(); |