[Mlir-commits] [mlir] [mlir][MemRefToLLVM] Fix crashes with unconvertable memory spaces (PR #70694)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Oct 30 10:36:06 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Krzysztof Drewniak (krzysz00)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/70694.diff
1 Files Affected:
- (modified) mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp (+4)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/70694
More information about the Mlir-commits
mailing list