Skip to content

Commit c7dbe7f

Browse files
committed
irshow: Fix CFG display with directly inserted new nodes
Slight fix to #47043 for the case where nodes where inserted using `insert_node_here!`.
1 parent 9744c7e commit c7dbe7f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

base/compiler/ssair/show.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,11 @@ function show_ir(io::IO, compact::IncrementalCompact, config::IRShowConfig=defau
918918
end
919919
end
920920

921+
still_to_be_inserted = (last(input_bb.stmts) - compact.idx) + count
922+
921923
result_bb = result_bbs[compact.active_result_bb]
922924
result_bbs[compact.active_result_bb] = Core.Compiler.BasicBlock(result_bb,
923-
Core.Compiler.StmtRange(first(result_bb.stmts), last(result_bb.stmts)+count))
925+
Core.Compiler.StmtRange(first(result_bb.stmts), compact.result_idx+still_to_be_inserted))
924926
end
925927
compact_cfg = CFG(result_bbs, Int[first(result_bbs[i].stmts) for i in 2:length(result_bbs)])
926928

test/show.jl

+11-1
Original file line numberDiff line numberDiff line change
@@ -2502,10 +2502,20 @@ end
25022502
# compact
25032503
compact = Core.Compiler.IncrementalCompact(ir)
25042504
verify_display(compact)
2505+
2506+
# Compact the first instruction
25052507
state = Core.Compiler.iterate(compact)
2506-
while state !== nothing
2508+
2509+
# Insert some instructions here
2510+
for i in 1:2
2511+
inst = Core.Compiler.NewInstruction(Expr(:call, :identity, i), Int, Int32(1))
2512+
Core.Compiler.insert_node_here!(compact, inst)
25072513
verify_display(compact)
2514+
end
2515+
2516+
while state !== nothing
25082517
state = Core.Compiler.iterate(compact, state[2])
2518+
verify_display(compact)
25092519
end
25102520

25112521
# complete

0 commit comments

Comments
 (0)