mirror of
https://github.com/intel/llvm.git
synced 2026-01-21 03:50:33 +08:00
[mlir][func] Guard for unranked memref with the bare ptr memref call
Lowering the call op with use-bare-ptr-memref-call crashes due to the unsupported unranked memref type. We can prevent the crash by checking the type of operand in the pass instead of the assertion in the type converter. Issue: https://github.com/llvm/llvm-project/issues/61872 Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D148078
This commit is contained in:
@@ -542,6 +542,16 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
|
||||
return failure();
|
||||
}
|
||||
|
||||
if (useBarePtrCallConv) {
|
||||
for (auto it : callOp->getOperands()) {
|
||||
Type operandType = it.getType();
|
||||
if (operandType.isa<UnrankedMemRefType>()) {
|
||||
// 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);
|
||||
|
||||
@@ -103,3 +103,14 @@ func.func @check_return(%in : memref<?xi8>) -> memref<?xi8> {
|
||||
func.func @unconvertible_multiresult(%arg0: memref<?xf32> , %arg1: memref<?xf32>) -> (memref<?xf32>, memref<?xf32>) {
|
||||
return %arg0, %arg1 : memref<?xf32>, memref<?xf32>
|
||||
}
|
||||
|
||||
// -----
|
||||
// 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>)
|
||||
|
||||
Reference in New Issue
Block a user