@@ -842,6 +842,26 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,
842
842
}
843
843
}
844
844
845
+ static void failForInvalidBundles (const CallBase &I, StringRef Name,
846
+ ArrayRef<uint32_t > AllowedBundles) {
847
+ if (I.hasOperandBundlesOtherThan (AllowedBundles)) {
848
+ std::string Error;
849
+ for (unsigned i = 0 , e = I.getNumOperandBundles (); i != e; ++i) {
850
+ OperandBundleUse U = I.getOperandBundleAt (i);
851
+ bool First = true ;
852
+ if (is_contained (AllowedBundles, U.getTagID ()))
853
+ continue ;
854
+ if (!First)
855
+ Error += " , " ;
856
+ First = false ;
857
+ Error += U.getTagName ();
858
+ }
859
+ reportFatalUsageError (
860
+ Twine (" cannot lower " , Name)
861
+ .concat (Twine (" with arbitrary operand bundles: " , Error)));
862
+ }
863
+ }
864
+
845
865
RegsForValue::RegsForValue (const SmallVector<Register, 4 > ®s, MVT regvt,
846
866
EVT valuevt, std::optional<CallingConv::ID> CC)
847
867
: ValueVTs(1 , valuevt), RegVTs(1 , regvt), Regs(regs),
@@ -3351,30 +3371,12 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
3351
3371
3352
3372
// Deopt and ptrauth bundles are lowered in helper functions, and we don't
3353
3373
// have to do anything here to lower funclet bundles.
3354
- constexpr uint32_t kAllowedBundles [] = {
3355
- LLVMContext::OB_deopt,
3356
- LLVMContext::OB_gc_transition,
3357
- LLVMContext::OB_gc_live,
3358
- LLVMContext::OB_funclet,
3359
- LLVMContext::OB_cfguardtarget,
3360
- LLVMContext::OB_ptrauth,
3361
- LLVMContext::OB_clang_arc_attachedcall,
3362
- LLVMContext::OB_kcfi};
3363
- if (I.hasOperandBundlesOtherThan (kAllowedBundles )) {
3364
- std::string Error;
3365
- for (unsigned i = 0 , e = I.getNumOperandBundles (); i != e; ++i) {
3366
- OperandBundleUse U = I.getOperandBundleAt (i);
3367
- bool First = true ;
3368
- if (is_contained (kAllowedBundles , U.getTagID ()))
3369
- continue ;
3370
- if (!First)
3371
- Error += " , " ;
3372
- First = false ;
3373
- Error += U.getTagName ();
3374
- }
3375
- reportFatalUsageError (
3376
- Twine (" cannot lower invokes with arbitrary operand bundles: " , Error));
3377
- }
3374
+ failForInvalidBundles (I, " invokes" ,
3375
+ {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
3376
+ LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
3377
+ LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth,
3378
+ LLVMContext::OB_clang_arc_attachedcall,
3379
+ LLVMContext::OB_kcfi});
3378
3380
3379
3381
const Value *Callee (I.getCalledOperand ());
3380
3382
const Function *Fn = dyn_cast<Function>(Callee);
@@ -3474,10 +3476,8 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) {
3474
3476
3475
3477
// Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
3476
3478
// have to do anything here to lower funclet bundles.
3477
- if (I.hasOperandBundlesOtherThan (
3478
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet}))
3479
- reportFatalUsageError (
3480
- " cannot lower callbrs with arbitrary operand bundles!" );
3479
+ failForInvalidBundles (I, " callbrs" ,
3480
+ {LLVMContext::OB_deopt, LLVMContext::OB_funclet});
3481
3481
3482
3482
assert (I.isInlineAsm () && " Only know how to handle inlineasm callbr" );
3483
3483
visitInlineAsm (I);
@@ -9585,12 +9585,12 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
9585
9585
// Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
9586
9586
// have to do anything here to lower funclet bundles.
9587
9587
// CFGuardTarget bundles are lowered in LowerCallTo.
9588
- if (I. hasOperandBundlesOtherThan (
9589
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet ,
9590
- LLVMContext::OB_cfguardtarget , LLVMContext::OB_preallocated ,
9591
- LLVMContext::OB_clang_arc_attachedcall , LLVMContext::OB_kcfi ,
9592
- LLVMContext::OB_convergencectrl}))
9593
- reportFatalUsageError ( " cannot lower calls with arbitrary operand bundles! " );
9588
+ failForInvalidBundles (
9589
+ I, " calls " ,
9590
+ { LLVMContext::OB_deopt , LLVMContext::OB_funclet ,
9591
+ LLVMContext::OB_cfguardtarget , LLVMContext::OB_preallocated ,
9592
+ LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi,
9593
+ LLVMContext::OB_convergencectrl} );
9594
9594
9595
9595
SDValue Callee = getValue (I.getCalledOperand ());
9596
9596
0 commit comments