Skip to content

Commit 419342b

Browse files
committed
Emit error message on the operation
Emit type conversion error message on the operation
1 parent b3eba80 commit 419342b

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

mlir/lib/Conversion/LLVMCommon/Pattern.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,8 @@ bool ConvertToLLVMPattern::isConvertibleAndHasIdentityMaps(
106106

107107
Type ConvertToLLVMPattern::getElementPtrType(MemRefType type) const {
108108
auto addressSpace = getTypeConverter()->getMemRefAddressSpace(type);
109-
if (failed(addressSpace)) {
110-
emitError(UnknownLoc::get(type.getContext()),
111-
"conversion of memref memory space ")
112-
<< type.getMemorySpace()
113-
<< " to integer address space "
114-
"failed. Consider adding memory space conversions.";
109+
if (failed(addressSpace))
115110
return {};
116-
}
117111
return LLVM::LLVMPointerType::get(type.getContext(), *addressSpace);
118112
}
119113

mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ std::tuple<Value, Value> AllocationOpLLVMLowering::allocateBufferManuallyAlign(
7474
MemRefType memRefType = getMemRefResultType(op);
7575
// Allocate the underlying buffer.
7676
Type elementPtrType = this->getElementPtrType(memRefType);
77+
if (!elementPtrType) {
78+
emitError(loc,"conversion of memref memory space ")
79+
<< memRefType.getMemorySpace()
80+
<< " to integer address space "
81+
"failed. Consider adding memory space conversions.";
82+
}
7783
LLVM::LLVMFuncOp allocFuncOp = getNotalignedAllocFn(
7884
getTypeConverter(), op->getParentWithTrait<OpTrait::SymbolTable>(),
7985
getIndexType());
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// RUN: mlir-opt %s -finalize-memref-to-llvm 2>&1 | FileCheck %s
2-
// Since the error is at an unknown location, we use FileCheck instead of
3-
// -veri-y-diagnostics here
1+
// RUN: mlir-opt %s -finalize-memref-to-llvm -verify-diagnostics
42

5-
// CHECK: conversion of memref memory space 1 : ui64 to integer address space failed. Consider adding memory space conversions.
63
// CHECK-LABEL: @invalid_int_conversion
74
func.func @invalid_int_conversion() {
8-
%alloc_0 = memref.alloc() {alignment = 64 : i64} : memref<10xf32, 1 : ui64>
5+
// expected-error@+1 {{conversion of memref memory space 1 : ui64 to integer address space failed. Consider adding memory space conversions.}}
6+
%alloc = memref.alloc() {alignment = 64 : i64} : memref<10xf32, 1 : ui64>
97
return
108
}

0 commit comments

Comments
 (0)