[Mlir-commits] [mlir] [mlir] [bufferize] fix crash when bufferize function without func.return returning op (PR #120675)
donald chen
llvmlistbot at llvm.org
Tue Jan 7 04:19:04 PST 2025
https://github.com/cxy-1993 updated https://github.com/llvm/llvm-project/pull/120675
>From 361bdf542a79c0b4798984f7fd98378d994217b0 Mon Sep 17 00:00:00 2001
From: donald chen <chenxunyu1993 at gmail.com>
Date: Tue, 7 Jan 2025 12:16:20 +0000
Subject: [PATCH] [mlir] [nfc] add assert for function 'getReturnOps'
Fixed https://github.com/llvm/llvm-project/issues/120535
---
.../Transforms/FuncBufferizableOpInterfaceImpl.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
index c45678f1e4b4dd..eba1ac4678773c 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
@@ -21,11 +21,12 @@
namespace mlir {
/// Return all func.return ops in the given function.
SmallVector<func::ReturnOp> bufferization::getReturnOps(func::FuncOp funcOp) {
- SmallVector<func::ReturnOp> result;
+ SmallVector<func::ReturnOp> results;
for (Block &b : funcOp.getBody())
if (auto returnOp = dyn_cast<func::ReturnOp>(b.getTerminator()))
- result.push_back(returnOp);
- return result;
+ results.push_back(returnOp);
+ assert(!results.empty() && "expected at least one ReturnOp");
+ return results;
}
namespace bufferization {
More information about the Mlir-commits
mailing list