[mlir] [transform] Fix for RAUW error in transform gpu dialect
authorGuray Ozen <guray.ozen@gmail.com>
Tue, 15 Nov 2022 17:49:35 +0000 (18:49 +0100)
committerGuray Ozen <guray.ozen@gmail.com>
Wed, 16 Nov 2022 08:55:24 +0000 (09:55 +0100)
commit63ca939783ebfc1ae3b16d4c26f9010631542078
tree2692ab9a4ab1a15fe7f7d807eb240e6e100b495d
parentb18cdeac79d0e084ac735fb1b9bbfd464d3d030c
[mlir] [transform] Fix for RAUW error in transform gpu dialect

The given test fails due to error below.

The following error is why the test is failing. One `memref.store` and two `memref.load` are consumers of the loop index for which I do RAUW. `memref.store` is first in the list. If I RAUW on this the loop of `llvm::make early inc range(threadIdx.getUsers())` does not return two `memref.load` as users. They remain unchanged. I'm not really certain why.

This change applies RAUW after collecting the users. If a better solution exists, I would be happy to implement it.

```
mlir-opt: ...llvm-project/mlir/include/mlir/IR/UseDefLists.h:175: mlir::IRObjectWithUseList<mlir::OpOperand>::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D138029
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
mlir/test/Dialect/GPU/transform-gpu.mlir