[Mlir-commits] [mlir] [mlir][IR] Add `Block::isReachable` helper function (PR #114928)
Mehdi Amini
llvmlistbot at llvm.org
Wed Nov 6 14:03:50 PST 2024
================
@@ -349,6 +352,23 @@ SuccessorRange::SuccessorRange(Operation *term) : SuccessorRange() {
base = term->getBlockOperands().data();
}
+bool Block::isReachable(Block *other, ArrayRef<Block *> except) {
+ assert(getParent() == other->getParent() && "expected same region");
+ SmallVector<Block *> worklist(succ_begin(), succ_end());
+ SmallPtrSet<Block *, 16> visited;
----------------
joker-eph wrote:
What about having the "except" parameters be a `SmallPtrSetImpl<Block *>` passed by copy (user should move) and use it to store the visited elements.
That way the user can still pre-populate it with blocks to skip, but we have one less check and one less data-structure around.
https://github.com/llvm/llvm-project/pull/114928
More information about the Mlir-commits
mailing list