Skip to content

Commit 40267bb

Browse files
authored
fix IRCode show_ir with verbose linetable (#40240)
fix block number printing with verbose linfo
1 parent 712abb0 commit 40267bb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

base/compiler/ssair/show.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
555555
else
556556
bb_guard_rail = bb_guard_rail_cont
557557
end
558+
floop = true
558559
# Print linetable information
559560
if verbose_linetable
560561
stack = compute_loc_stack(code.linetable, stmt[:line])
@@ -568,10 +569,11 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
568569
printstyled(io, "\e[$(start_column)G$(rail)\e[1G", color = :light_black)
569570
print(io, bb_guard_rail)
570571
ssa_guard = " "^(maxlength_idx + 4 + (i - 1))
571-
entry_label = "$(ssa_guard)$(method_name(entry)) at $(entry.file):$(entry[:line]) "
572+
entry_label = "$(ssa_guard)$(method_name(entry)) at $(entry.file):$(entry.line) "
572573
hline = string(""^(start_column-length(entry_label)-length(bb_guard_rail)+max_depth-i), "")
573574
printstyled(io, string(entry_label, hline), "\n"; color=:light_black)
574575
bb_guard_rail = bb_guard_rail_cont
576+
floop = false
575577
end
576578
end
577579
printstyled(io, "\e[$(start_column)G$(rail)\e[1G", color = :light_black)
@@ -602,7 +604,6 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
602604
if idx == last(bbrange)
603605
print_sep = true
604606
end
605-
floop = true
606607
# print new nodes first in the right position
607608
while perm_idx <= length(new_nodes_perm)
608609
node_idx = new_nodes_perm[perm_idx]

test/show.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,12 @@ let src = code_typed(my_fun28173, (Int,), debuginfo=:source)[1][1]
18901890
@test pop!(lines2) == "\$(QuoteNode(4))"
18911891
@test pop!(lines2) == "17 │ \$(QuoteNode(3))" # TODO: this should print after the next statement
18921892
@test lines1 == lines2
1893+
1894+
# verbose linetable
1895+
io = IOBuffer()
1896+
Base.IRShow.show_ir(io, ir; verbose_linetable=true)
1897+
seekstart(io)
1898+
@test count(contains(r"my_fun28173 at none:\d+"), eachline(io)) == 9
18931899
end
18941900

18951901
# Verify that extra instructions at the end of the IR

0 commit comments

Comments
 (0)