Skip to content

Commit 4ff4981

Browse files
committed
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.
1 parent 8413b97 commit 4ff4981

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

base/compiler/ssair/domtree.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,7 @@ function SNCA!(domtree::GenericDomTree{IsPostDom}, blocks::Vector{BasicBlock}, m
345345
ancestors = copy(D.to_parent_pre)
346346
relevant_blocks = IsPostDom ? (1:max_pre) : (2:max_pre)
347347
for w::PreNumber in reverse(relevant_blocks)
348-
# LLVM initializes this to the parent, the paper initializes this to
349-
# `w`, but it doesn't really matter (the parent is a predecessor, so at
350-
# worst we'll discover it below). Save a memory reference here.
351-
semi_w = typemax(PreNumber)
348+
semi_w = ancestors[w]
352349
last_linked = PreNumber(w + 1)
353350
for v dom_edges(domtree, blocks, D.from_pre[w])
354351
# For the purpose of the domtree, ignore virtual predecessors into

0 commit comments

Comments
 (0)