Skip to content

Commit

Permalink
irinterp: Don't try to rekill fall-through terminators (#49815)
Browse files Browse the repository at this point in the history
If a fall-through terminator was already Bottom, we should not attempt
to rekill the successor edge, because it was already deleted.
Yet another fix in the #49692, #49750, #49797 series, which is
turning out to be quite a rabit hole. Also fix a typo in the
verifer tweak where we were looking at the BB idx rather than
the terminator idx.
  • Loading branch information
Keno authored May 15, 2023
1 parent d489203 commit b9806d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion base/compiler/ssair/irinterp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, irsv::IR
any_refined = true
delete!(ssa_refined, idx)
end
is_terminator_or_phi = isa(inst, PhiNode) || isa(inst, GotoNode) || isa(inst, GotoIfNot) || isa(inst, ReturnNode) || isexpr(inst, :enter)
if typ === Bottom && (idx != lstmt || !is_terminator_or_phi)
continue
end
if any_refined && reprocess_instruction!(interp,
idx, bb, inst, typ, irsv, extra_reprocess)
push!(ssa_refined, idx)
inst = ir.stmts[idx][:inst]
typ = ir.stmts[idx][:type]
end
if typ === Bottom && !(isa(inst, PhiNode) || isa(inst, GotoNode) || isa(inst, GotoIfNot) || isa(inst, ReturnNode) || isexpr(inst, :enter))
if typ === Bottom && !is_terminator_or_phi
kill_terminator_edges!(irsv, lstmt, bb)
if idx != lstmt
for idx2 in (idx+1:lstmt-1)
Expand Down
6 changes: 4 additions & 2 deletions base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ function verify_ir(ir::IRCode, print::Bool=true,
end
isa(stmt, PhiNode) || break
end
if isempty(block.succs) && ir.stmts[idx][:type] == Union{}
termidx = last(block.stmts)
stmttyp = ir.stmts[termidx][:type]
if isempty(block.succs) && stmttyp == Union{}
# Allow fallthrough terminators that are known to error to
# be removed from the CFG. Ideally we'd add an unreachable
# here, but that isn't always possible.
else
@verify_error "Block $idx successors ($(block.succs)), does not match fall-through terminator ($terminator)"
@verify_error "Block $idx successors ($(block.succs)), does not match fall-through terminator %$termidx ($terminator)::$stmttyp"
error("")
end
end
Expand Down

0 comments on commit b9806d6

Please sign in to comment.