diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -542,6 +542,16 @@ return failure(); } + if (useBarePtrCallConv) { + for (auto it : callOp->getOperands()) { + Type operandType = it.getType(); + if (operandType.isa()) { + // Unranked memref is not supported in the bare pointer calling + // convention. + return failure(); + } + } + } auto promoted = this->getTypeConverter()->promoteOperands( callOp.getLoc(), /*opOperands=*/callOp->getOperands(), adaptor.getOperands(), rewriter, useBarePtrCallConv); diff --git a/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir b/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir --- a/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir +++ b/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir @@ -103,3 +103,14 @@ func.func @unconvertible_multiresult(%arg0: memref , %arg1: memref) -> (memref, memref) { return %arg0, %arg1 : memref, memref } + +// ----- +// BAREPTR-LABEL: func @unranked_memref( +// BAREPTR-SAME: %{{.*}}: memref<*xi32>) +func.func @unranked_memref(%arg0:memref<*xi32>) { + // BAREPTR: call @printMemrefI32(%arg{{.*}}) : (memref<*xi32>) -> () + // BAREPTR-NEXT: llvm.return + call @printMemrefI32(%arg0) : (memref<*xi32>) -> () + return +} +func.func private @printMemrefI32(memref<*xi32>)