Skip to content

Commit

Permalink
Fix handling of virtual exit node in PostDomTree
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
topolarity committed Mar 14, 2024
1 parent 8413b97 commit 4ff4981
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions base/compiler/ssair/domtree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ff4981

Please sign in to comment.