================ @@ -77,17 +77,38 @@ void CIRGenFunction::emitAggregateStore(mlir::Value value, Address dest) { builder.createStore(*currSrcLoc, value, dest); } +static void addAttributesFromFunctionProtoType(CIRGenBuilderTy &builder, + mlir::NamedAttrList &attrs, + const FunctionProtoType *fpt) { + if (!fpt) + return; + + if (!isUnresolvedExceptionSpec(fpt->getExceptionSpecType()) && + fpt->isNothrow()) + attrs.set("nothrow", mlir::UnitAttr::get(builder.getContext())); +} + /// Construct the CIR attribute list of a function or call. void CIRGenModule::constructAttributeList(CIRGenCalleeInfo calleeInfo, - cir::SideEffect &sideEffect) { + mlir::NamedAttrList &attrs) { assert(!cir::MissingFeatures::opCallCallConv()); - sideEffect = cir::SideEffect::All; + auto sideEffect = cir::SideEffect::All; - assert(!cir::MissingFeatures::opCallAttrs()); + addAttributesFromFunctionProtoType(getBuilder(), attrs, + calleeInfo.getCalleeFunctionProtoType()); const Decl *targetDecl = calleeInfo.getCalleeDecl().getDecl(); if (targetDecl) { + if (targetDecl->hasAttr<NoThrowAttr>()) + attrs.set("nothrow", mlir::UnitAttr::get(&getMLIRContext())); ---------------- bcardosolopes wrote:
See `extraClassDeclaration` in `LLVMDialect.td`, we should do similar with attribute names, and here it would become a `getNoThrowAttrName()` call. https://github.com/llvm/llvm-project/pull/145178 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits