ryancbuckley opened PR #15299 from ryancbuckley:fix/domtree-unreachable-dominates to bytecodealliance:main:
Before this change, DominatorTree::block_dominates() determined if a
block A dominates a block B by checking whether A's preorder range
([dom_pre_number, dom_pre_max]) contains B's. Since unreachable blocks
are never visited when computing the dominator tree, their range stays
[0, 0]. This madeblock_dominatesreturntruefor any pair of
unreachable blocks.This bug broke PostDominatorTree, which runs DominatorTree on the
reversed CFG. Blocks in an infinite loop can't reach a function exit, so
they are unreachable in the reversed CFG. As a result, any two blocks
in an infinite loop appeared to post-dominate each other, causing
dead-store elimination to drop live stores.This change fixes the bug by checking in block_dominates() whether a
block is unreachable (na.dom_pre_number != 0), so an unreachable block
only dominates itself.I found the check_post_dominance() test to be a natural fit for testing this.
Before this change, it skipped testing blocks that diverge, but I have
reordered it slightly so it can check that dominator relationships are correct
even for blocks that diverge.The [0, 0] preorder range check was introduced in #11596, but the bug
was not exposed until PostDominatorTree (#13736) and cross-block
dead-store elimination (#13806) began running it on diverging loops a few
months ago.
ryancbuckley removed the review request for wasmtime-compiler-reviewers from PR #15299.
ryancbuckley requested alexcrichton for a review on PR #15299.
ryancbuckley requested wasmtime-compiler-reviewers for a review on PR #15299.
github-actions[bot] added the label cranelift on PR #15299.
bjorn3 commented on PR #15299:
If one unreachable block jumps to another, will this cause a verifier error about non-dominating defs if the second block tries to use a value defined in the first block?
alexcrichton removed the review request for alexcrichton from PR #15299.
alexcrichton requested fitzgen for a review on PR #15299.
ryancbuckley commented on PR #15299:
If one unreachable block jumps to another, will this cause a verifier error about non-dominating defs if the second block tries to use a value defined in the first block?
I don't think so. It looks like the verifier gates its dominance checks on is_reachable: instructions, blocks
Last updated: Nov 19 2026 at 20:05 UTC