generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | ||
---|---|---|
1045–1047 | This would be wrong. You can't assume getDefiningOp always returns non-null. This will crash if the yielded value is a BlockArgument. |
Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | ||
---|---|---|
1045–1047 | Thanks for pointing out. I have fixed it and updated the test cases. Please review. |
Mostly related to code comments and redundancy.
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | ||
---|---|---|
1040–1043 | If the yielded value | |
1040–1043 | An SSA value can never be updated. Please rephrase. | |
1041 | Nit: it's -> its | |
1041–1042 | Again, please rewrite. An SSA value can't be updated. | |
1045–1047 | Please avoid != nullptr -- it's not consistent with the style used and is also more verbose. In addition, the more idiomatic way would be: !..isa<BlockArgument>(). You don't need to obtain the defining op pointer. | |
1045–1047 | The check also has redundancy/repetition between the two clauses. Instead: Operation *defOp = ...; if (defOp && defOp->getBlock() == ...) |
[MLIR][Affine] Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block or if it is a BlockArgument then the cloned value
and it's corresponding mapping won't exist, resulting in a crash. Fix this.
Differential Revision: https://reviews.llvm.org/D146931
Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
Differential Revision: https://reviews.llvm.org/D146931
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | ||
---|---|---|
1040–1043 | Update. Please re-review. |
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | ||
---|---|---|
1045 | This will eliminate an extra check: Operation *defOp = ...; if (defOp && defOp->getBlock() == ...) |
Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
Differential Revision: https://reviews.llvm.org/D146931
Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
git diff --check HEAD~ mlir/test/Dialect/SCF/loop-unroll.mlir:8: trailing whitespace. +// RUN: mlir-opt %s --affine-loop-unroll --split-input-file | FileCheck %s
Please fix.
mlir/test/Dialect/SCF/loop-unroll.mlir | ||
---|---|---|
8 | Trailing white space here. |
Fix generateUnrolledLoop utility
generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.
Nit: it's -> its