From 6b535630a1222ff1e535989242dbad8513df2eb2 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 22 Mar 2016 17:51:25 +0000 Subject: [PATCH] Add a hasOperandBundlesOtherThan helper, and use it; NFC llvm-svn: 264072 --- llvm/include/llvm/IR/InstrTypes.h | 11 +++++++++++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 18 ++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index ef86eba..e52fa5b 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1478,6 +1478,17 @@ public: Other.bundle_op_info_begin()); }; + /// \brief Return true if this operand bundle user contains operand bundles + /// with tags other than those specified in \p IDs. + bool hasOperandBundlesOtherThan(ArrayRef IDs) const { + for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) { + uint32_t ID = getOperandBundleAt(i).getTagID(); + if (std::find(IDs.begin(), IDs.end(), ID) == IDs.end()) + return true; + } + return false; + } + protected: /// \brief Is the function attribute S disallowed by some operand bundle on /// this operand bundle user? diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index d01dd98..6f65361 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2127,14 +2127,11 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) { MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)]; const BasicBlock *EHPadBB = I.getSuccessor(1); -#ifndef NDEBUG // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't // have to do anything here to lower funclet bundles. - for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) - assert((I.getOperandBundleAt(i).isDeoptOperandBundle() || - I.getOperandBundleAt(i).isFuncletOperandBundle()) && - "Cannot lower invokes with arbitrary operand bundles yet!"); -#endif + assert(!I.hasOperandBundlesOtherThan( + {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) && + "Cannot lower invokes with arbitrary operand bundles yet!"); const Value *Callee(I.getCalledValue()); const Function *Fn = dyn_cast(Callee); @@ -6116,14 +6113,11 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { RenameFn, DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout())); -#ifndef NDEBUG // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't // have to do anything here to lower funclet bundles. - for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) - assert((I.getOperandBundleAt(i).isDeoptOperandBundle() || - I.getOperandBundleAt(i).isFuncletOperandBundle()) && - "Cannot lower calls with arbitrary operand bundles!"); -#endif + assert(!I.hasOperandBundlesOtherThan( + {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) && + "Cannot lower calls with arbitrary operand bundles!"); if (I.countOperandBundlesOfType(LLVMContext::OB_deopt)) LowerCallSiteWithDeoptBundle(&I, Callee, nullptr); -- 2.7.4