diff options
| author | Matthias Springer <mspringer@nvidia.com> | 2025-04-07 14:54:25 +0200 |
|---|---|---|
| committer | Matthias Springer <mspringer@nvidia.com> | 2025-04-07 14:54:25 +0200 |
| commit | 1e4475dcd0541f9fad941816011bebd4e6264056 (patch) | |
| tree | 0a8b4d5b4ace9fac25690cfbccde19a55a917182 | |
| parent | bafa2f4442bcee26f05c22369d41646d5c8befb9 (diff) | |
[mlir][LLVM] Do not emit error in type converterusers/matthias-springer/type_conv_error
| -rw-r--r-- | mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp | 15 | ||||
| -rw-r--r-- | mlir/test/Conversion/MemRefToLLVM/invalid.mlir | 40 | ||||
| -rw-r--r-- | mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir | 19 |
3 files changed, 24 insertions, 50 deletions
diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp index ea251e4564ea..060ea3c26529 100644 --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp @@ -485,27 +485,16 @@ LLVMTypeConverter::convertFunctionTypeCWrapper(FunctionType type) const { SmallVector<Type, 5> LLVMTypeConverter::getMemRefDescriptorFields(MemRefType type, bool unpackAggregates) const { - if (!type.isStrided()) { - emitError( - UnknownLoc::get(type.getContext()), - "conversion to strided form failed either due to non-strided layout " - "maps (which should have been normalized away) or other reasons"); + if (!type.isStrided()) return {}; - } Type elementType = convertType(type.getElementType()); if (!elementType) return {}; FailureOr<unsigned> addressSpace = getMemRefAddressSpace(type); - if (failed(addressSpace)) { - emitError(UnknownLoc::get(type.getContext()), - "conversion of memref memory space ") - << type.getMemorySpace() - << " to integer address space " - "failed. Consider adding memory space conversions."; + if (failed(addressSpace)) return {}; - } auto ptrTy = LLVM::LLVMPointerType::get(type.getContext(), *addressSpace); auto indexTy = getIndexType(); diff --git a/mlir/test/Conversion/MemRefToLLVM/invalid.mlir b/mlir/test/Conversion/MemRefToLLVM/invalid.mlir index 0d04bba96bcd..ffaf7f1a7a3e 100644 --- a/mlir/test/Conversion/MemRefToLLVM/invalid.mlir +++ b/mlir/test/Conversion/MemRefToLLVM/invalid.mlir @@ -1,42 +1,8 @@ -// RUN: mlir-opt %s -finalize-memref-to-llvm -split-input-file -verify-diagnostics | FileCheck %s +// RUN: mlir-opt %s -finalize-memref-to-llvm -split-input-file -verify-diagnostics // expected-error@+1{{redefinition of reserved function 'malloc' of different type '!llvm.func<void (i64)>' is prohibited}} llvm.func @malloc(i64) func.func @redef_reserved() { - %alloc = memref.alloc() : memref<1024x64xf32, 1> - llvm.return -} - -// ----- - -// expected-error@unknown{{conversion of memref memory space "foo" to integer address space failed. Consider adding memory space conversions.}} -// CHECK-LABEL: @bad_address_space -func.func @bad_address_space(%a: memref<2xindex, "foo">) { - %c0 = arith.constant 0 : index - // CHECK: memref.store - memref.store %c0, %a[%c0] : memref<2xindex, "foo"> - return -} - -// ----- - -// CHECK-LABEL: @invalid_int_conversion -func.func @invalid_int_conversion() { - // expected-error@unknown{{conversion of memref memory space 1 : ui64 to integer address space failed. Consider adding memory space conversions.}} - %alloc = memref.alloc() {alignment = 64 : i64} : memref<10xf32, 1 : ui64> - return -} - -// ----- - -// expected-error@unknown{{conversion of memref memory space #gpu.address_space<workgroup> to integer address space failed. Consider adding memory space conversions}} -// CHECK-LABEL: @issue_70160 -func.func @issue_70160() { - %alloc = memref.alloc() : memref<1x32x33xi32, #gpu.address_space<workgroup>> - %alloc1 = memref.alloc() : memref<i32> - %c0 = arith.constant 0 : index - // CHECK: memref.load - %0 = memref.load %alloc[%c0, %c0, %c0] : memref<1x32x33xi32, #gpu.address_space<workgroup>> - memref.store %0, %alloc1[] : memref<i32> - func.return + %alloc = memref.alloc() : memref<1024x64xf32, 1> + llvm.return } diff --git a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir index 12e93c96f743..681c6fe798bb 100644 --- a/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir +++ b/mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir @@ -665,3 +665,22 @@ func.func @alloca_unconvertable_memory_space() { %alloca = memref.alloca() : memref<1x32x33xi32, #spirv.storage_class<StorageBuffer>> func.return } + +// ----- + +// CHECK-LABEL: @alloc_unconvertable_memory_space +func.func @alloc_unconvertable_memory_space() { + // CHECK: memref.alloc + %alloc = memref.alloc() {alignment = 64 : i64} : memref<10xf32, 1 : ui64> + return +} + +// ----- + +// CHECK-LABEL: @bad_address_space +func.func @bad_address_space(%a: memref<2xindex, "foo">) { + %c0 = arith.constant 0 : index + // CHECK: memref.store + memref.store %c0, %a[%c0] : memref<2xindex, "foo"> + return +} |
