[Mlir-commits] [mlir] [MLIR] Fix -remove-dead-values with external function & deleted arguments (PR #99671)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Aug 4 00:16:48 PDT 2024
================
@@ -1124,15 +1124,15 @@ static void getGenericEffectsImpl(
&effects,
LinalgOp linalgOp) {
for (auto [index, operand] : llvm::enumerate(linalgOp.getDpsInputs())) {
- if (!llvm::isa<MemRefType>(operand.getType()))
+ if (!operand || !llvm::isa<MemRefType>(operand.getType()))
----------------
huang-me wrote:
```mlir
%cst_2 = arith.constant dense<[[1., 2., 3.], [4., 5., 6.]]> : tensor<2x3xf64>
%cst_3 = arith.constant dense<0.> : tensor<3x2xf64>
%transposed = linalg.transpose ins(%cst_2 : tensor<2x3xf64>) outs(%cst_3 : tensor<3x2xf64>) permutation = [1, 0]
return
```
In example above, `%cst_2`, `%cst_3`, `transposed` are dead values since they are not used, however, we drop uses and erase these values in order and turning the content of the region into something similar to snippet below.
```
%transposed = linalg.transpose ins(nullptr) outs(nullptr) permutation = [1, 0]
return
```
We've checked the liveness of values before removing them, so I think we should not assert while removing dead values.
If we don't want to check whether arguments have been removed, we may need to change the removing order into reverse chronological order.
https://github.com/llvm/llvm-project/pull/99671
More information about the Mlir-commits
mailing list