// Returns the static shape of the provided type if possible.
auto getConstantShape = [&](llvm::Type *type) {
- return llvm::dyn_cast_if_present<ShapedType>(getBuiltinTypeForAttr(convertType(type))
- );
+ return llvm::dyn_cast_if_present<ShapedType>(
+ getBuiltinTypeForAttr(convertType(type)));
};
// Convert one-dimensional constant arrays or vectors that store 1/2/4/8-byte
// Convert zero aggregates.
if (auto *constZero = dyn_cast<llvm::ConstantAggregateZero>(constant)) {
- auto shape = llvm::dyn_cast_if_present<ShapedType>(getBuiltinTypeForAttr(convertType(constZero->getType()))
- );
+ auto shape = llvm::dyn_cast_if_present<ShapedType>(
+ getBuiltinTypeForAttr(convertType(constZero->getType())));
if (!shape)
return {};
// Convert zero aggregates with a static shape to splat elements attributes.
// Convert the result attributes and attach them wrapped in an ArrayAttribute
// to the funcOp.
llvm::AttributeSet llvmResAttr = llvmAttrs.getRetAttrs();
+ if (!llvmResAttr.hasAttributes())
+ return;
funcOp.setResAttrsAttr(
builder.getArrayAttr(convertParameterAttribute(llvmResAttr, builder)));
}
--- /dev/null
+; RUN: mlir-translate -import-llvm -split-input-file %s --mlir-print-op-generic | FileCheck %s
+
+; Ensure that no empty parameter attribute lists are created.
+; CHECK: "llvm.func"
+; CHECK-SAME: <{
+; CHECK-NOT: arg_attr
+; CHECK-NOT: res_attrs
+; CHECK-SAME: }>
+declare ptr @func_no_param_attrs()