diff options
author | Florian Mayer <fmayer@google.com> | 2025-07-15 17:30:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-15 17:30:48 -0700 |
commit | 5458151817c5f46c05a6b7c472085e51aa55c892 (patch) | |
tree | 4139ec874e07f17186139aaaeea0b2ff9c9f0dde /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | 82d7405b3bb911c86d0b07c8a6bec5044acbdf66 (diff) | |
download | llvm-5458151817c5f46c05a6b7c472085e51aa55c892.zip llvm-5458151817c5f46c05a6b7c472085e51aa55c892.tar.gz llvm-5458151817c5f46c05a6b7c472085e51aa55c892.tar.bz2 |
[SelectionDAG] improve error messages for invalid operator bundle (#148945)
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 4954e23..74c14ed 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -842,6 +842,26 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL, } } +static void failForInvalidBundles(const CallBase &I, StringRef Name, + ArrayRef<uint32_t> AllowedBundles) { + if (I.hasOperandBundlesOtherThan(AllowedBundles)) { + std::string Error; + for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) { + OperandBundleUse U = I.getOperandBundleAt(i); + bool First = true; + if (is_contained(AllowedBundles, U.getTagID())) + continue; + if (!First) + Error += ", "; + First = false; + Error += U.getTagName(); + } + reportFatalUsageError( + Twine("cannot lower ", Name) + .concat(Twine(" with arbitrary operand bundles: ", Error))); + } +} + RegsForValue::RegsForValue(const SmallVector<Register, 4> ®s, MVT regvt, EVT valuevt, std::optional<CallingConv::ID> CC) : ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(regs), @@ -3351,30 +3371,12 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) { // Deopt and ptrauth bundles are lowered in helper functions, and we don't // have to do anything here to lower funclet bundles. - constexpr uint32_t kAllowedBundles[] = { - LLVMContext::OB_deopt, - LLVMContext::OB_gc_transition, - LLVMContext::OB_gc_live, - LLVMContext::OB_funclet, - LLVMContext::OB_cfguardtarget, - LLVMContext::OB_ptrauth, - LLVMContext::OB_clang_arc_attachedcall, - LLVMContext::OB_kcfi}; - if (I.hasOperandBundlesOtherThan(kAllowedBundles)) { - std::string Error; - for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) { - OperandBundleUse U = I.getOperandBundleAt(i); - bool First = true; - if (is_contained(kAllowedBundles, U.getTagID())) - continue; - if (!First) - Error += ", "; - First = false; - Error += U.getTagName(); - } - reportFatalUsageError( - Twine("cannot lower invokes with arbitrary operand bundles: ", Error)); - } + failForInvalidBundles(I, "invokes", + {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition, + LLVMContext::OB_gc_live, LLVMContext::OB_funclet, + LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth, + LLVMContext::OB_clang_arc_attachedcall, + LLVMContext::OB_kcfi}); const Value *Callee(I.getCalledOperand()); const Function *Fn = dyn_cast<Function>(Callee); @@ -3474,10 +3476,8 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) { // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't // have to do anything here to lower funclet bundles. - if (I.hasOperandBundlesOtherThan( - {LLVMContext::OB_deopt, LLVMContext::OB_funclet})) - reportFatalUsageError( - "cannot lower callbrs with arbitrary operand bundles!"); + failForInvalidBundles(I, "callbrs", + {LLVMContext::OB_deopt, LLVMContext::OB_funclet}); assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr"); visitInlineAsm(I); @@ -9585,12 +9585,12 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't // have to do anything here to lower funclet bundles. // CFGuardTarget bundles are lowered in LowerCallTo. - if (I.hasOperandBundlesOtherThan( - {LLVMContext::OB_deopt, LLVMContext::OB_funclet, - LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated, - LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi, - LLVMContext::OB_convergencectrl})) - reportFatalUsageError("cannot lower calls with arbitrary operand bundles!"); + failForInvalidBundles( + I, "calls", + {LLVMContext::OB_deopt, LLVMContext::OB_funclet, + LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated, + LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi, + LLVMContext::OB_convergencectrl}); SDValue Callee = getValue(I.getCalledOperand()); |