@@ -334,16 +334,17 @@ static void AddAttributesFromFunctionProtoType(CIRGenBuilderTy &builder,
334334// / target-configuration logic, as well as for code defined in library
335335// / modules such as CUDA's libdevice.
336336// /
337- // / - ConstructAttributeList builds on top of getDefaultFunctionAttributes
337+ // / - constructAttributeList builds on top of getDefaultFunctionAttributes
338338// / and adds declaration-specific, convention-specific, and
339339// / frontend-specific logic. The last is of particular importance:
340340// / attributes that restrict how the frontend generates code must be
341341// / added here rather than getDefaultFunctionAttributes.
342342// /
343- void CIRGenModule::ConstructAttributeList (StringRef Name,
343+ void CIRGenModule::constructAttributeList (StringRef Name,
344344 const CIRGenFunctionInfo &FI,
345345 CIRGenCalleeInfo CalleeInfo,
346- mlir::DictionaryAttr &Attrs,
346+ mlir::NamedAttrList &funcAttrs,
347+ mlir::cir::CallingConv &callingConv,
347348 bool AttrOnCallSite, bool IsThunk) {
348349 // Implementation Disclaimer
349350 //
@@ -355,13 +356,13 @@ void CIRGenModule::ConstructAttributeList(StringRef Name,
355356 // That said, for the most part, the approach here is very specific compared
356357 // to the rest of CIRGen and attributes and other handling should be done upon
357358 // demand.
358- mlir::NamedAttrList FuncAttrs;
359359
360360 // Collect function CIR attributes from the CC lowering.
361+ callingConv = FI.getEffectiveCallingConvention ();
361362 // TODO: NoReturn, cmse_nonsecure_call
362363
363364 // Collect function CIR attributes from the callee prototype if we have one.
364- AddAttributesFromFunctionProtoType (getBuilder (), astCtx, FuncAttrs ,
365+ AddAttributesFromFunctionProtoType (getBuilder (), astCtx, funcAttrs ,
365366 CalleeInfo.getCalleeFunctionProtoType ());
366367
367368 const Decl *TargetDecl = CalleeInfo.getCalleeDecl ().getDecl ();
@@ -378,12 +379,12 @@ void CIRGenModule::ConstructAttributeList(StringRef Name,
378379
379380 if (TargetDecl->hasAttr <NoThrowAttr>()) {
380381 auto nu = mlir::cir::NoThrowAttr::get (builder.getContext ());
381- FuncAttrs .set (nu.getMnemonic (), nu);
382+ funcAttrs .set (nu.getMnemonic (), nu);
382383 }
383384
384385 if (const FunctionDecl *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
385386 AddAttributesFromFunctionProtoType (
386- getBuilder (), astCtx, FuncAttrs ,
387+ getBuilder (), astCtx, funcAttrs ,
387388 Fn->getType ()->getAs <FunctionProtoType>());
388389 if (AttrOnCallSite && Fn->isReplaceableGlobalAllocationFunction ()) {
389390 // A sane operator new returns a non-aliasing pointer.
@@ -439,8 +440,6 @@ void CIRGenModule::ConstructAttributeList(StringRef Name,
439440 if (TargetDecl->hasAttr <ArmLocallyStreamingAttr>())
440441 ;
441442 }
442-
443- Attrs = mlir::DictionaryAttr::get (builder.getContext (), FuncAttrs);
444443}
445444
446445static mlir::cir::CIRCallOpInterface
@@ -679,11 +678,14 @@ RValue CIRGenFunction::buildCall(const CIRGenFunctionInfo &CallInfo,
679678 // TODO: Update the largest vector width if any arguments have vector types.
680679
681680 // Compute the calling convention and attributes.
682- mlir::DictionaryAttr Attrs;
681+ mlir::NamedAttrList Attrs;
683682 StringRef FnName;
684683 if (auto calleeFnOp = dyn_cast<mlir::cir::FuncOp>(CalleePtr))
685684 FnName = calleeFnOp.getName ();
686- CGM.ConstructAttributeList (FnName, CallInfo, Callee.getAbstractInfo (), Attrs,
685+
686+ mlir::cir::CallingConv callingConv;
687+ CGM.constructAttributeList (FnName, CallInfo, Callee.getAbstractInfo (), Attrs,
688+ callingConv,
687689 /* AttrOnCallSite=*/ true ,
688690 /* IsThunk=*/ false );
689691
@@ -716,7 +718,7 @@ RValue CIRGenFunction::buildCall(const CIRGenFunctionInfo &CallInfo,
716718 } else {
717719 // Otherwise, nounwind call sites will never throw.
718720 auto noThrowAttr = mlir::cir::NoThrowAttr::get (builder.getContext ());
719- CannotThrow = Attrs.contains (noThrowAttr.getMnemonic ());
721+ CannotThrow = Attrs.getNamed (noThrowAttr.getMnemonic ()). has_value ( );
720722
721723 if (auto fptr = dyn_cast<mlir::cir::FuncOp>(CalleePtr))
722724 if (fptr.getExtraAttrs ().getElements ().contains (
@@ -760,10 +762,12 @@ RValue CIRGenFunction::buildCall(const CIRGenFunctionInfo &CallInfo,
760762 indirectFuncVal = CalleePtr->getResult (0 );
761763 }
762764
763- mlir::cir::CIRCallOpInterface callLikeOp = buildCallLikeOp (
764- *this , callLoc, indirectFuncTy, indirectFuncVal, directFuncOp,
765- CIRCallArgs, InvokeDest,
766- mlir::cir::ExtraFuncAttributesAttr::get (builder.getContext (), Attrs));
765+ auto extraFnAttrs = mlir::cir::ExtraFuncAttributesAttr::get (
766+ builder.getContext (), Attrs.getDictionary (builder.getContext ()));
767+
768+ mlir::cir::CIRCallOpInterface callLikeOp =
769+ buildCallLikeOp (*this , callLoc, indirectFuncTy, indirectFuncVal,
770+ directFuncOp, CIRCallArgs, InvokeDest, extraFnAttrs);
767771
768772 if (E)
769773 callLikeOp->setAttr (
0 commit comments