[Mlir-commits] [mlir] [mlir][bufferization] Fix to_buffer being incorrectly hoisted by LICM (PR #188997)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Mar 27 06:55:09 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

* 7731 tests passed
* 604 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### MLIR
<details>
<summary>MLIR.Dialect/Tensor/bufferize.mlir</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/mlir-opt /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir --one-shot-bufferize="dialect-filter=tensor,bufferization copy-before-write unknown-type-conversion=identity-layout-map" -cse -split-input-file | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/mlir-opt /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir '--one-shot-bufferize=dialect-filter=tensor,bufferization copy-before-write unknown-type-conversion=identity-layout-map' -cse -split-input-file
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir:572:16: error: CHECK-DAG: expected string not found in input
# |  // CHECK-DAG: %[[dim0:.*]] = memref.dim %[[m1]], %[[c0]]
# |                ^
# | <stdin>:428:91: note: scanning from here
# |  func.func @tensor.pad(%arg0: tensor<?x10xindex>, %arg1: index, %arg2: index, %arg3: index) -> tensor<?x?xindex> {
# |                                                                                           ^
# | <stdin>:428:91: note: with "m1" equal to "0"
# |  func.func @tensor.pad(%arg0: tensor<?x10xindex>, %arg1: index, %arg2: index, %arg3: index) -> tensor<?x?xindex> {
# |                                                                                           ^
# | <stdin>:428:91: note: with "c0" equal to "c0"
# |  func.func @tensor.pad(%arg0: tensor<?x10xindex>, %arg1: index, %arg2: index, %arg3: index) -> tensor<?x?xindex> {
# |                                                                                           ^
# | <stdin>:435:2: note: possible intended match here
# |  %dim = memref.dim %4, %c0 : memref<?x10xindex>
# |  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir:639:11: error: CHECK: expected string not found in input
# | // CHECK: %[[SUBVIEW2:.*]] = memref.subview %[[ALLOC]][8] [8] [1]
# |           ^
# | <stdin>:495:26: note: scanning from here
# |  memref.copy %0, %subview_0 : memref<8xf32> to memref<8xf32, strided<[1], offset: 8>>
# |                          ^
# | <stdin>:495:26: note: with "ALLOC" equal to "alloc"
# |  memref.copy %0, %subview_0 : memref<8xf32> to memref<8xf32, strided<[1], offset: 8>>
# |                          ^
# | <stdin>:495:38: note: possible intended match here
# |  memref.copy %0, %subview_0 : memref<8xf32> to memref<8xf32, strided<[1], offset: 8>>
# |                                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir:681:11: error: CHECK: expected string not found in input
# | // CHECK: %[[SUBVIEW1:.*]] = memref.subview %[[ALLOC]][0, 0] [8, %[[F_DIM]]] [1, 1]
# |           ^
# | <stdin>:528:68: note: scanning from here
# |  %alloc = memref.alloc(%4) {alignment = 64 : i64} : memref<8x?xf32>
# |                                                                    ^
# | <stdin>:528:68: note: with "ALLOC" equal to "alloc"
# |  %alloc = memref.alloc(%4) {alignment = 64 : i64} : memref<8x?xf32>
# |                                                                    ^
# | <stdin>:528:68: note: with "F_DIM" equal to "dim"
# |  %alloc = memref.alloc(%4) {alignment = 64 : i64} : memref<8x?xf32>
# |                                                                    ^
# | <stdin>:530:8: note: possible intended match here
# |  %subview = memref.subview %alloc[0, 0] [8, %dim_1] [1, 1] : memref<8x?xf32> to memref<8x?xf32, strided<[?, 1]>>
# |        ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir:707:11: error: CHECK: expected string not found in input
# | // CHECK: %[[SUBVIEW1:.*]] = memref.subview %[[ALLOC]][0, 0] [%[[NON_CONCAT_DIM]], %[[F_DIM]]] [1, 1]
# |           ^
# | <stdin>:556:33: note: scanning from here
# |  %dim_2 = memref.dim %alloc, %c0 : memref<?x?xf32>
# |                                 ^
# | <stdin>:556:33: note: with "ALLOC" equal to "alloc"
# |  %dim_2 = memref.dim %alloc, %c0 : memref<?x?xf32>
# |                                 ^
# | <stdin>:556:33: note: with "NON_CONCAT_DIM" equal to "dim_2"
# |  %dim_2 = memref.dim %alloc, %c0 : memref<?x?xf32>
# |                                 ^
# | <stdin>:556:33: note: with "F_DIM" equal to "dim_0"
# |  %dim_2 = memref.dim %alloc, %c0 : memref<?x?xf32>
# |                                 ^
# | <stdin>:558:6: note: possible intended match here
# |  %subview = memref.subview %alloc[0, 0] [%dim_2, %dim_3] [1, 1] : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1]>>
# |      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir:737:44: error: undefined variable: $sum_map
# | // CHECK: %[[OFFSET:.*]] = affine.apply #[[$sum_map]]()[%[[F_DIM]], %[[G_DIM]]]
# |                                            ^
# | <stdin>:582:28: note: with "F_DIM" equal to "dim"
# |  memref.copy %1, %subview_1 : memref<8x?xf32> to memref<8x?xf32, strided<[10, 1], offset: ?>>
# |                            ^
# | <stdin>:582:28: note: with "G_DIM" equal to "dim_0"
# |  memref.copy %1, %subview_1 : memref<8x?xf32> to memref<8x?xf32, strided<[10, 1], offset: ?>>
# |                            ^
# | <stdin>:583:2: note: possible intended match here
# |  %3 = affine.apply #map()[%dim, %dim_0]
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/mlir/test/Dialect/Tensor/bufferize.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |            423:  
# |            424: // ----- 
# |            425: #map = affine_map<()[s0, s1] -> (s0 + s1 + 5)> 
# |            426: #map1 = affine_map<()[s0, s1] -> (s0 + s1 + 10)> 
# |            427: module { 
# |            428:  func.func @tensor.pad(%arg0: tensor<?x10xindex>, %arg1: index, %arg2: index, %arg3: index) -> tensor<?x?xindex> { 
# | dag:572'0                                                                                                 X~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | dag:572'1                                                                                                                           with "m1" equal to "0"
# | dag:572'2                                                                                                                           with "c0" equal to "c0"
# |            429:  %0 = bufferization.to_buffer %arg0 : tensor<?x10xindex> to memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            430:  %1 = bufferization.to_buffer %arg0 : tensor<?x10xindex> to memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            431:  %2 = bufferization.to_buffer %arg0 : tensor<?x10xindex> to memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            432:  %3 = bufferization.to_buffer %arg0 : tensor<?x10xindex> to memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            433:  %4 = bufferization.to_buffer %arg0 : tensor<?x10xindex> to memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            434:  %c0 = arith.constant 0 : index 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            435:  %dim = memref.dim %4, %c0 : memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | dag:572'3        ?                                               possible intended match
# |            436:  %c5 = arith.constant 5 : index 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            437:  %c1 = arith.constant 1 : index 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            438:  %dim_0 = memref.dim %3, %c1 : memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            439:  %dim_1 = memref.dim %2, %c0 : memref<?x10xindex> 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            440:  %5 = affine.apply #map()[%dim_1, %arg2] 
# | dag:572'0       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |            490:  %1 = bufferization.to_buffer %arg0 : tensor<8xf32> to memref<8xf32> 
# |            491:  %alloc = memref.alloc() {alignment = 64 : i64} : memref<16xf32> 
# |            492:  %subview = memref.subview %alloc[0] [8] [1] : memref<16xf32> to memref<8xf32, strided<[1]>> 
# |            493:  memref.copy %1, %subview : memref<8xf32> to memref<8xf32, strided<[1]>> 
# |            494:  %subview_0 = memref.subview %alloc[8] [8] [1] : memref<16xf32> to memref<8xf32, strided<[1], offset: 8>> 
# |            495:  memref.copy %0, %subview_0 : memref<8xf32> to memref<8xf32, strided<[1], offset: 8>> 
# | check:639'0                              X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | check:639'1                                                                                            with "ALLOC" equal to "alloc"
# | check:639'2                                          ?                                                 possible intended match
# |            496:  %2 = bufferization.to_tensor %alloc : memref<16xf32> to tensor<16xf32> 
# | check:639'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            497:  return %2 : tensor<16xf32> 
# | check:639'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            498:  } 
# | check:639'0     ~~~
# |            499: } 
# | check:639'0     ~~
# |            500:  
# | check:639'0     ~
# |              .
# |              .
# |              .
# |            523:  %3 = bufferization.to_buffer %arg0 : tensor<8x?xf32> to memref<8x?xf32> 
# |            524:  %c1 = arith.constant 1 : index 
# |            525:  %dim = memref.dim %1, %c1 : memref<8x?xf32> 
# |            526:  %dim_0 = memref.dim %0, %c1 : memref<8x?xf32> 
# |            527:  %4 = affine.apply #map()[%dim, %dim_0] 
# |            528:  %alloc = memref.alloc(%4) {alignment = 64 : i64} : memref<8x?xf32> 
# | check:681'0                                                                        X error: no match found
# | check:681'1                                                                          with "ALLOC" equal to "alloc"
# | check:681'2                                                                          with "F_DIM" equal to "dim"
# |            529:  %dim_1 = memref.dim %3, %c1 : memref<8x?xf32> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            530:  %subview = memref.subview %alloc[0, 0] [8, %dim_1] [1, 1] : memref<8x?xf32> to memref<8x?xf32, strided<[?, 1]>> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:681'3            ?                                                                                                          possible intended match
# |            531:  memref.copy %3, %subview : memref<8x?xf32> to memref<8x?xf32, strided<[?, 1]>> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            532:  %dim_2 = memref.dim %2, %c1 : memref<8x?xf32> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            533:  %subview_3 = memref.subview %alloc[0, %dim_1] [8, %dim_2] [1, 1] : memref<8x?xf32> to memref<8x?xf32, strided<[?, 1], offset: ?>> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            534:  memref.copy %2, %subview_3 : memref<8x?xf32> to memref<8x?xf32, strided<[?, 1], offset: ?>> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            535:  %5 = bufferization.to_tensor %alloc : memref<8x?xf32> to tensor<8x?xf32> 
# | check:681'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |            551:  %c1 = arith.constant 1 : index 
# |            552:  %dim_0 = memref.dim %1, %c1 : memref<?x?xf32> 
# |            553:  %dim_1 = memref.dim %0, %c1 : memref<?x?xf32> 
# |            554:  %5 = affine.apply #map()[%dim_0, %dim_1] 
# |            555:  %alloc = memref.alloc(%dim, %5) {alignment = 64 : i64} : memref<?x?xf32> 
# |            556:  %dim_2 = memref.dim %alloc, %c0 : memref<?x?xf32> 
# | check:707'0                                     X~~~~~~~~~~~~~~~~~~ error: no match found
# | check:707'1                                                         with "ALLOC" equal to "alloc"
# | check:707'2                                                         with "NON_CONCAT_DIM" equal to "dim_2"
# | check:707'3                                                         with "F_DIM" equal to "dim_0"
# |            557:  %dim_3 = memref.dim %4, %c1 : memref<?x?xf32> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            558:  %subview = memref.subview %alloc[0, 0] [%dim_2, %dim_3] [1, 1] : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1]>> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:707'4          ?                                                                                                                 possible intended match
# |            559:  memref.copy %4, %subview : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1]>> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            560:  %dim_4 = memref.dim %3, %c1 : memref<?x?xf32> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            561:  %subview_5 = memref.subview %alloc[0, %dim_3] [%dim_2, %dim_4] [1, 1] : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1], offset: ?>> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            562:  memref.copy %3, %subview_5 : memref<?x?xf32> to memref<?x?xf32, strided<[?, 1], offset: ?>> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            563:  %6 = bufferization.to_tensor %alloc : memref<?x?xf32> to tensor<?x?xf32> 
# | check:707'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |            577:  %dim = memref.dim %2, %c1 : memref<8x?xf32> 
# |            578:  %subview = memref.subview %alloc[0, 0] [8, %dim] [1, 1] : memref<8x10xf32> to memref<8x?xf32, strided<[10, 1]>> 
# |            579:  memref.copy %2, %subview : memref<8x?xf32> to memref<8x?xf32, strided<[10, 1]>> 
# |            580:  %dim_0 = memref.dim %1, %c1 : memref<8x?xf32> 
# |            581:  %subview_1 = memref.subview %alloc[0, %dim] [8, %dim_0] [1, 1] : memref<8x10xf32> to memref<8x?xf32, strided<[10, 1], offset: ?>> 
# |            582:  memref.copy %1, %subview_1 : memref<8x?xf32> to memref<8x?xf32, strided<[10, 1], offset: ?>> 
# | check:737'0                                X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: match failed for invalid pattern
# | check:737'1                                                                                                    undefined variable: $sum_map
# | check:737'2                                                                                                    with "F_DIM" equal to "dim"
# | check:737'3                                                                                                    with "G_DIM" equal to "dim_0"
# |            583:  %3 = affine.apply #map()[%dim, %dim_0] 
# | check:737'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:737'4      ?                                       possible intended match
# |            584:  %subview_2 = memref.subview %alloc[0, %3] [8, 2] [1, 1] : memref<8x10xf32> to memref<8x2xf32, strided<[10, 1], offset: ?>> 
# | check:737'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            585:  memref.copy %0, %subview_2 : memref<8x2xf32> to memref<8x2xf32, strided<[10, 1], offset: ?>> 
# | check:737'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            586:  %4 = bufferization.to_tensor %alloc : memref<8x10xf32> to tensor<8x10xf32> 
# | check:737'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            587:  return %4 : tensor<8x10xf32> 
# | check:737'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            588:  } 
# | check:737'0     ~~~
# |              .
# |              .
# |              .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

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


More information about the Mlir-commits mailing list