Skip to content

Commit b9806d6

Browse files
authored
irinterp: Don't try to rekill fall-through terminators (#49815)
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.
1 parent d489203 commit b9806d6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

base/compiler/ssair/irinterp.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,17 @@ function _ir_abstract_constant_propagation(interp::AbstractInterpreter, irsv::IR
247247
any_refined = true
248248
delete!(ssa_refined, idx)
249249
end
250+
is_terminator_or_phi = isa(inst, PhiNode) || isa(inst, GotoNode) || isa(inst, GotoIfNot) || isa(inst, ReturnNode) || isexpr(inst, :enter)
251+
if typ === Bottom && (idx != lstmt || !is_terminator_or_phi)
252+
continue
253+
end
250254
if any_refined && reprocess_instruction!(interp,
251255
idx, bb, inst, typ, irsv, extra_reprocess)
252256
push!(ssa_refined, idx)
253257
inst = ir.stmts[idx][:inst]
254258
typ = ir.stmts[idx][:type]
255259
end
256-
if typ === Bottom && !(isa(inst, PhiNode) || isa(inst, GotoNode) || isa(inst, GotoIfNot) || isa(inst, ReturnNode) || isexpr(inst, :enter))
260+
if typ === Bottom && !is_terminator_or_phi
257261
kill_terminator_edges!(irsv, lstmt, bb)
258262
if idx != lstmt
259263
for idx2 in (idx+1:lstmt-1)

base/compiler/ssair/verify.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ function verify_ir(ir::IRCode, print::Bool=true,
174174
end
175175
isa(stmt, PhiNode) || break
176176
end
177-
if isempty(block.succs) && ir.stmts[idx][:type] == Union{}
177+
termidx = last(block.stmts)
178+
stmttyp = ir.stmts[termidx][:type]
179+
if isempty(block.succs) && stmttyp == Union{}
178180
# Allow fallthrough terminators that are known to error to
179181
# be removed from the CFG. Ideally we'd add an unreachable
180182
# here, but that isn't always possible.
181183
else
182-
@verify_error "Block $idx successors ($(block.succs)), does not match fall-through terminator ($terminator)"
184+
@verify_error "Block $idx successors ($(block.succs)), does not match fall-through terminator %$termidx ($terminator)::$stmttyp"
183185
error("")
184186
end
185187
end

0 commit comments

Comments
 (0)