[Mlir-commits] [mlir] [mlir] [bufferize] fix crash when bufferize function without func.return returning op (PR #120675)

Matthias Springer llvmlistbot at llvm.org
Tue Dec 24 06:20:02 PST 2024


================
@@ -268,4 +268,10 @@ func.func @materialize_in_dest_raw(%f: f32, %f2: f32, %idx: index) -> (tensor<5x
   %r = tensor.extract %dest_filled[%idx] : tensor<5xf32>
 
   return %0, %r : tensor<5xf32>, f32
-}
\ No newline at end of file
+}
+
+// -----
+// CHECK-LABEL: @llvm_return
+func.func @llvm_return() {
+   llvm.return
----------------
matthias-springer wrote:

If this is just meant to avoid the crash, I would replace this like:
```c++
  assert(!returnOps.empty() && "expected at least one ReturnOp");
```

With `return failure();` and maybe `emitOpError`.

Also note the name of one of the files: `FuncBufferizableOpInterfaceImpl.cpp`. This is a func-dialect specific implementation.


https://github.com/llvm/llvm-project/pull/120675


More information about the Mlir-commits mailing list