diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -51,10 +51,8 @@ ArrayRef argAttrs); static void build(OpBuilder &builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef attrs); - static void build(OpBuilder &builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef attrs, - ArrayRef argAttrs); + FunctionType type, ArrayRef attrs = {}, + ArrayRef argAttrs = {}); /// Operation hooks. static ParseResult parse(OpAsmParser &parser, OperationState &result); diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -124,8 +124,7 @@ // Declare vulkan launch function. builder.create( loc, kVulkanLaunch, - FunctionType::get(vulkanLaunchTypes, ArrayRef{}, loc->getContext()), - ArrayRef{}); + FunctionType::get(vulkanLaunchTypes, {}, loc->getContext())); return success(); } diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp --- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp +++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp @@ -79,8 +79,7 @@ rewriter.setInsertionPoint(module.getBody(), std::prev(module.getBody()->end())); FuncOp funcOp = - rewriter.create(op->getLoc(), fnNameAttr.getValue(), libFnType, - ArrayRef{}); + rewriter.create(op->getLoc(), fnNameAttr.getValue(), libFnType); // Insert a function attribute that will trigger the emission of the // corresponding `_mlir_ciface_xxx` interface so that external libraries see // a normalized ABI. This interface is added during std to llvm conversion. diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -42,18 +42,16 @@ } void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef attrs) { + FunctionType type, ArrayRef attrs, + ArrayRef argAttrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), builder.getStringAttr(name)); result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); result.attributes.append(attrs.begin(), attrs.end()); result.addRegion(); -} -void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef attrs, - ArrayRef argAttrs) { - build(builder, result, name, type, attrs); + if (argAttrs.empty()) + return; assert(type.getNumInputs() == argAttrs.size()); SmallString<8> argAttrName; for (unsigned i = 0, e = type.getNumInputs(); i != e; ++i)