[mlir] Make topologicalSort iterative and consider op regions
authorthomasraoux <thomasraoux@google.com>
Wed, 10 Nov 2021 02:11:33 +0000 (18:11 -0800)
committerthomasraoux <thomasraoux@google.com>
Wed, 10 Nov 2021 18:05:01 +0000 (10:05 -0800)
commit5aa6038a407451da2ca5438c5b03c40aa4c72aad
tree8eae5fbeb8159a11319a540860399ea06e69ffbe
parente068c84762ac1ec34631beb5f41cebfa78fcc3df
[mlir] Make topologicalSort iterative and consider op regions

When doing topological sort we need to make sure an op is scheduled before any
of the ops within its regions.
Also change the algorithm to not be recursive in order to prevent potential
stack overflow.

Differential Revision: https://reviews.llvm.org/D113423
mlir/lib/Analysis/SliceAnalysis.cpp
mlir/test/Analysis/test-topoligical-sort.mlir [new file with mode: 0644]
mlir/test/lib/Analysis/CMakeLists.txt
mlir/test/lib/Analysis/TestSlice.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp