[Mlir-commits] [mlir] [mlir][MemRefToLLVM] Fix crashes with unconvertable memory spaces (PR #70694)
Krzysztof Drewniak
llvmlistbot at llvm.org
Mon Oct 30 10:36:00 PDT 2023
https://github.com/krzysz00 updated https://github.com/llvm/llvm-project/pull/70694
>From 6919e73d973c2d1635b4afcbca49606717241619 Mon Sep 17 00:00:00 2001
From: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
Date: Mon, 30 Oct 2023 17:32:08 +0000
Subject: [PATCH] [mlir][MemRefToLLVM] Fix crashes with unconvertable memory
spaces
Fixes #70160
The issue is resolved by:
1. Changing the call to address space conversion to use the correct
return type, preventing the code from moving past the if and into the
crashing optional dereference.
2. Adding handling to the AllocLikeOp rewriter for the case where the
underlying buffer allocation fails.
---
mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp b/mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp
index a2a426e3c293175..dfc47dffe0d2166 100644
--- a/mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp
+++ b/mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp
@@ -183,6 +183,10 @@ LogicalResult AllocLikeOpLLVMLowering::matchAndRewrite(
auto [allocatedPtr, alignedPtr] =
this->allocateBuffer(rewriter, loc, size, op);
+ if (!allocatedPtr || !alignedPtr)
+ return rewriter.notifyMatchFailure(loc,
+ "underlying buffer allocation failed");
+
// Create the MemRef descriptor.
auto memRefDescriptor = this->createMemRefDescriptor(
loc, memRefType, allocatedPtr, alignedPtr, sizes, strides, rewriter);
More information about the Mlir-commits
mailing list