File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
lib/Conversion/LLVMCommon
test/Conversion/MemRefToLLVM Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,14 @@ bool ConvertToLLVMPattern::isConvertibleAndHasIdentityMaps(
106106
107107Type ConvertToLLVMPattern::getElementPtrType (MemRefType type) const {
108108 auto addressSpace = getTypeConverter ()->getMemRefAddressSpace (type);
109- if (failed (addressSpace))
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." ;
110115 return {};
116+ }
111117 return LLVM::LLVMPointerType::get (type.getContext (), *addressSpace);
112118}
113119
Original file line number Diff line number Diff line change @@ -527,8 +527,10 @@ LLVMTypeConverter::getMemRefAddressSpace(BaseMemRefType type) const {
527527 return failure ();
528528 if (!(*converted)) // Conversion to default is 0.
529529 return 0 ;
530- if (auto explicitSpace = llvm::dyn_cast_if_present<IntegerAttr>(*converted))
531- return explicitSpace.getInt ();
530+ if (auto explicitSpace = llvm::dyn_cast_if_present<IntegerAttr>(*converted)) {
531+ if (explicitSpace.getType ().isSignedInteger ())
532+ return explicitSpace.getInt ();
533+ }
532534 return failure ();
533535}
534536
Original file line number Diff line number Diff line change 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
4+
5+ // CHECK: conversion of memref memory space 1 : ui64 to integer address space failed. Consider adding memory space conversions.
6+ // CHECK-LABEL: @invalid_int_conversion
7+ func.func @invalid_int_conversion () {
8+ %alloc_0 = memref.alloc () {alignment = 64 : i64 } : memref <10 xf32 , 1 : ui64 >
9+ return
10+ }
You can’t perform that action at this time.
0 commit comments