[mlir] Linalg : do not forward memrefs to outputs when do bufferization
authorEugene Zhulenev <ezhulenev@google.com>
Wed, 21 Apr 2021 22:52:50 +0000 (15:52 -0700)
committerEugene Zhulenev <ezhulenev@google.com>
Wed, 21 Apr 2021 23:39:06 +0000 (16:39 -0700)
commit3f1e827abd7fb893f7a33f467126d5d736ffa8d4
treea47370eb0ac03c23047a6f48c433f567e3d7ce34
parentac303795a7862ae0e3b50a5d1a9ff4914a141338
[mlir] Linalg : do not forward memrefs to outputs when do bufferization

Example:
```
%0 = linalg.init_tensor : tensor<...>
%1 = linalg.generic ... outs(%0: tensor<...>)
%2 = linalg.generic ... outs(%0: tensor<...>)
```

Memref allocated as a result of `init_tensor` bufferization can be incorrectly overwritten by the second linalg.generic operation

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D100921
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/test/Dialect/Linalg/bufferize.mlir