diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp index 86394aa969bb..4fd5b9c43a54 100644 --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -542,6 +542,16 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern { 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 index 956c298123db..c1f41d270e7e 100644 --- a/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir +++ b/mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir @@ -103,3 +103,14 @@ func.func @check_return(%in : memref) -> memref { 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>)