|
1 | 1 | // RUN: mlir-opt %s --test-transform-dialect-interpreter \
|
2 | 2 | // RUN: --test-transform-dialect-erase-schedule \
|
3 | 3 | // RUN: --math-uplift-to-fma \
|
| 4 | +// RUN: --convert-bufferization-to-memref \ |
4 | 5 | // RUN: --test-lower-to-llvm |\
|
5 | 6 | // RUN: FileCheck %s
|
6 | 7 |
|
@@ -307,10 +308,22 @@ module attributes { transform.with_named_sequence } {
|
307 | 308 | // transformation process, so invalidation is not an issue. However, if
|
308 | 309 | // other transformations, such as loop unrolling, are required after
|
309 | 310 | // bufferization, new handles should be produced using the match operations.
|
| 311 | + // |
| 312 | + // One-shot bufferization itself does not produce buffer deallocations, |
| 313 | + // which may lead to leaks. So we have to run the buffer deallocation pass |
| 314 | + // pipeline to avoid them. Note that the transform dialect seamlessly runs |
| 315 | + // named passes and pass pipelines: if desired, one could replace complex |
| 316 | + // --pass-pipeline expressions with operations. Note that we apply the |
| 317 | + // pipeline to functions rather than entire module to avoid running it |
| 318 | + // on the transform IR that is contained in the module. |
310 | 319 | %arg1 = transform.bufferization.one_shot_bufferize %arg0 {
|
311 | 320 | bufferize_function_boundaries = true,
|
312 | 321 | function_boundary_type_conversion = 1 : i32 }
|
313 | 322 | : (!transform.any_op) -> !transform.any_op
|
| 323 | + %f = transform.structured.match ops{["func.func"]} in %arg1 |
| 324 | + : (!transform.any_op) -> !transform.any_op |
| 325 | + transform.apply_registered_pass "buffer-deallocation-pipeline" to %f |
| 326 | + : (!transform.any_op) -> !transform.any_op |
314 | 327 |
|
315 | 328 | // Apply general canonicalization and CSE to each function after
|
316 | 329 | // bufferization as new simplification opportunities may have appeared.
|
|
0 commit comments