Files
clang-p2996/mlir/test/Dialect/ControlFlow/one-shot-bufferize-invalid.mlir
Matthias Springer 6ecebb496c [mlir][bufferization] Support unstructured control flow
This revision adds support for unstructured control flow to the bufferization infrastructure. In particular: regions with multiple blocks, `cf.br`, `cf.cond_br`.

Two helper templates are added to `BufferizableOpInterface.h`, which can be implemented by ops that supported unstructured control flow in their regions (e.g., `func.func`) and ops that branch to another block (e.g., `cf.br`).

A block signature is always bufferized together with the op that owns the block.

Differential Revision: https://reviews.llvm.org/D158094
2023-08-31 12:55:53 +02:00

25 lines
923 B
MLIR

// RUN: mlir-opt -one-shot-bufferize="allow-return-allocs bufferize-function-boundaries" -split-input-file %s -verify-diagnostics
// expected-error @below{{failed to bufferize op}}
// expected-error @below{{incoming operands of block argument have inconsistent memory spaces}}
func.func @inconsistent_memory_space() -> tensor<5xf32> {
%0 = bufferization.alloc_tensor() {memory_space = 0 : ui64} : tensor<5xf32>
cf.br ^bb1(%0: tensor<5xf32>)
^bb1(%arg1: tensor<5xf32>):
func.return %arg1 : tensor<5xf32>
^bb2():
%1 = bufferization.alloc_tensor() {memory_space = 1 : ui64} : tensor<5xf32>
cf.br ^bb1(%1: tensor<5xf32>)
}
// -----
// expected-error @below{{failed to bufferize op}}
// expected-error @below{{could not infer buffer type of block argument}}
func.func @cannot_infer_type() {
return
// The type of the block argument cannot be inferred.
^bb1(%t: tensor<5xf32>):
cf.br ^bb1(%t: tensor<5xf32>)
}