<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/146015>146015</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR][Affine] affine-pipeline-data-transfer-pass erases op attributes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sherylll
      </td>
    </tr>
</table>

<pre>
    version: 20.1.7

input:
```
// RUN: mlir-opt %s -affine-pipeline-data-transfer 
func.func @loop_nest_dma() {

  %A = memref.alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0>
  %Ah = memref.alloc() {alignment = 1024} : memref<32 x f32, affine_map<(d0) -> (d0)>, 1>

  %tag = memref.alloc() : memref<1 x f32>

  %zero = arith.constant 0 : index
  %num_elts = arith.constant 32 : index

  affine.for %i = 0 to 8 {
    affine.dma_start %A[%i], %Ah[%i], %tag[%zero], %num_elts : memref<256 x f32>, memref<32 x f32, 1>, memref<1 x f32>
    affine.dma_wait %tag[%zero], %num_elts : memref<1 x f32>
    %v = affine.load %Ah[%i] : memref<32 x f32, affine_map<(d0) -> (d0)>, 1>
  }
  memref.dealloc %tag : memref<1 x f32>
  memref.dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1>
 return
}
```
output:
```
#map = affine_map<(d0) -> (d0 - 1)>
#map1 = affine_map<(d0) -> (d0 mod 2)>
module {
  func.func @loop_nest_dma() {
 ...
    %alloc_1 = memref.alloc() : memref<2x32xf32, 1> // attributes get removed
    %alloc_2 = memref.alloc() : memref<2x1xf32>
 affine.dma_start %alloc[%c0], %alloc_1[%c0 mod 2, %c0], %alloc_2[%c0 mod 2, 0], %c32 : memref<256xf32>, memref<2x32xf32, 1>, memref<2x1xf32>
 affine.for %arg0 = 1 to 8 {
      affine.dma_start %alloc[%arg0], %alloc_1[%arg0 mod 2, %arg0], %alloc_2[%arg0 mod 2, 0], %c32 : memref<256xf32>, memref<2x32xf32, 1>, memref<2x1xf32>
      %4 = affine.apply #map(%arg0)
      %5 = affine.apply #map1(%4)
      %6 = affine.apply #map1(%4)
      affine.dma_wait %alloc_2[%4 mod 2, 0], %c32 : memref<2x1xf32>
      %7 = affine.load %alloc_1[%4 mod 2, %4] : memref<2x32xf32, 1>
    }
    ...
    return
  }
}
```

The alignment attribute is lost during this pass. Is this expected behavior? If not, adding an argument `cast<memref::AllocOp>(oldMemRef.getDefiningOp())->getAttrs()` to this line [this line](https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Affine/Transforms/PipelineDataTransfer.cpp#L105) should fix the issue. 

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VkGPozgT_TXOpRRkbAjJIQe6M5FGmvnm02j2HJlgwCuDkW2y6f31KxtISEKk9GpWajXBrnLVq3p-FDNGlA3nWxS_oXi3YJ2tlN6aiusPKeUiU_nH9sS1EapBNAWCgzBIEE4RTkXTdhZR9xOt8PCHU0T2iOzh5x__cw61FHqpWguIxAaWrChEw5etaLl0P3Jm2dJq1piCa0A4LbrmGLh_gCIslWoPDTf2kNcMkTUiG0DJWx8e3JEpILqDmteaFwGTUh1HMxfbLyP6TuIVnKGgBJF36FM41KxF9B2RdY6d_RLRLzC-IfrFWWL3HANVTyMlb0yKsql5Y71NiEmEkt1tCpT8mwzCPoMxCcvKl_CGQ6wb57-5Vt6baWGr4KgaY1ljAXtf0eT8PJo2XX3g0po5c0pu7L1LDygolHbewrthsArWQ7sALkZ5zQ7GMu0ZkTrakVigeOfg-jo_LFlW9msOwXV5kuRsq_sKzjYgvN-8Kdhdsn8xYT-dxsOBiMSnvpz9yVKx_B7vb2QMAEp2_jlwJeeeLVcWPU_20cOT_7elprntdOO441Ocaofq7BNNoTVrJ_V7Hg-WEA4xR7_wNcda5UAurrXKO8kv_H1RlyAIgmvHfQEP4WsadabkPOEnDDrKrNUi6yw3UH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