[PATCH] D137945: [ObjC][ARC] Share bundle handling code between steps of the ObjCARCOpts pass and cleanup (NFC)
Stefan Gränitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 06:17:50 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13a85a78cfea: [ObjC][ARC] Share bundle handling code between steps of the ObjCARCOpts pass… (authored by sgraenitz).
Changed prior to commit:
https://reviews.llvm.org/D137945?vs=483746&id=491751#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137945/new/
https://reviews.llvm.org/D137945
Files:
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/test/Transforms/ObjCARC/funclet-cleanuppad.ll
llvm/test/Transforms/ObjCARC/funclet.ll
Index: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
===================================================================
--- llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -567,25 +567,15 @@
void OptimizeReturns(Function &F);
- Instruction *cloneCallInstForBB(CallInst &CI, BasicBlock &BB) {
- SmallVector<OperandBundleDef, 1> OpBundles;
- for (unsigned I = 0, E = CI.getNumOperandBundles(); I != E; ++I) {
- auto Bundle = CI.getOperandBundleAt(I);
- // Funclets will be reassociated in the future.
- if (Bundle.getTagID() == LLVMContext::OB_funclet)
- continue;
- OpBundles.emplace_back(Bundle);
+ template <typename PredicateT>
+ static void cloneOpBundlesIf(CallBase *CI,
+ SmallVectorImpl<OperandBundleDef> &OpBundles,
+ PredicateT Predicate) {
+ for (unsigned I = 0, E = CI->getNumOperandBundles(); I != E; ++I) {
+ OperandBundleUse B = CI->getOperandBundleAt(I);
+ if (Predicate(B))
+ OpBundles.emplace_back(B);
}
-
- if (!BlockEHColors.empty()) {
- const ColorVector &CV = BlockEHColors.find(&BB)->second;
- assert(CV.size() > 0 && "non-unique color for block!");
- Instruction *EHPad = CV.front()->getFirstNonPHI();
- if (EHPad->isEHPad())
- OpBundles.emplace_back("funclet", EHPad);
- }
-
- return CallInst::Create(&CI, OpBundles);
}
void addOpBundleForFunclet(BasicBlock *BB,
@@ -1152,8 +1142,12 @@
continue;
Value *Op = PN->getIncomingValue(i);
Instruction *InsertPos = &PN->getIncomingBlock(i)->back();
- CallInst *Clone =
- cast<CallInst>(cloneCallInstForBB(*CInst, *InsertPos->getParent()));
+ SmallVector<OperandBundleDef, 1> OpBundles;
+ cloneOpBundlesIf(CInst, OpBundles, [](const OperandBundleUse &B) {
+ return B.getTagID() != LLVMContext::OB_funclet;
+ });
+ addOpBundleForFunclet(InsertPos->getParent(), OpBundles);
+ CallInst *Clone = CallInst::Create(CInst, OpBundles);
if (Op->getType() != ParamTy)
Op = new BitCastInst(Op, ParamTy, "", InsertPos);
Clone->setArgOperand(0, Op);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137945.491751.patch
Type: text/x-patch
Size: 2212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230124/598da902/attachment.bin>
More information about the llvm-commits
mailing list