Skip to content

Commit a2b6426

Browse files
authored
Fix insert_node_here! if called at the end of the IR (#39021)
This method was throwing an error when called after the compaction had processes the last instruction in the IR (with reverse affinity). This currently can't, because we never use this method after compacting a terminal instruction (inlining uses it to split BBs), but can after the new code in #37849, so fix the bug now. Forward port from #37849.
1 parent 770e228 commit a2b6426

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

base/compiler/ssair/ir.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ end
708708
function insert_node_here!(compact::IncrementalCompact, @nospecialize(val), @nospecialize(typ), ltable_idx::Int32, reverse_affinity::Bool=false)
709709
refinish = false
710710
result_idx = compact.result_idx
711-
if result_idx == first(compact.result_bbs[compact.active_result_bb].stmts) && reverse_affinity
711+
if reverse_affinity &&
712+
((compact.active_result_bb == length(compact.result_bbs) + 1) ||
713+
result_idx == first(compact.result_bbs[compact.active_result_bb].stmts))
712714
compact.active_result_bb -= 1
713715
refinish = true
714716
end

0 commit comments

Comments
 (0)