Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irinterp: Don't try to rekill fall-through terminators #49815

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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