From 935ada262799d6d80f78c5b0dd7695c05b010bbf Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Thu, 14 Mar 2024 05:28:42 -0400 Subject: [PATCH] Fix handling of virtual exit node in PostDomTree The `dom_edges()` for an exit block in the CFG are empty when computing the PostDomTree, although the algorithm is supposed to treat this as being dominated by a "virtual" -1 node (which is already included in the DFSTree). As a result, we can't rely on the loop below this code to initialize the semi-dominator correctly for us. --- base/compiler/ssair/domtree.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/base/compiler/ssair/domtree.jl b/base/compiler/ssair/domtree.jl index dfe0550d7a06d..bbae3a4d8c0fc 100644 --- a/base/compiler/ssair/domtree.jl +++ b/base/compiler/ssair/domtree.jl @@ -345,10 +345,7 @@ function SNCA!(domtree::GenericDomTree{IsPostDom}, blocks::Vector{BasicBlock}, m ancestors = copy(D.to_parent_pre) relevant_blocks = IsPostDom ? (1:max_pre) : (2:max_pre) for w::PreNumber in reverse(relevant_blocks) - # LLVM initializes this to the parent, the paper initializes this to - # `w`, but it doesn't really matter (the parent is a predecessor, so at - # worst we'll discover it below). Save a memory reference here. - semi_w = typemax(PreNumber) + semi_w = ancestors[w] last_linked = PreNumber(w + 1) for v ∈ dom_edges(domtree, blocks, D.from_pre[w]) # For the purpose of the domtree, ignore virtual predecessors into