Skip to content

Commit

Permalink
fix IRCode show_ir with verbose linetable (JuliaLang#40240)
Browse files Browse the repository at this point in the history
fix block number printing with verbose linfo
  • Loading branch information
simeonschaub authored and johanmon committed Jul 5, 2021
1 parent 9ea1040 commit 9e35ded
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/compiler/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
else
bb_guard_rail = bb_guard_rail_cont
end
floop = true
# Print linetable information
if verbose_linetable
stack = compute_loc_stack(code.linetable, stmt[:line])
Expand All @@ -568,10 +569,11 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
printstyled(io, "\e[$(start_column)G$(rail)\e[1G", color = :light_black)
print(io, bb_guard_rail)
ssa_guard = " "^(maxlength_idx + 4 + (i - 1))
entry_label = "$(ssa_guard)$(method_name(entry)) at $(entry.file):$(entry[:line]) "
entry_label = "$(ssa_guard)$(method_name(entry)) at $(entry.file):$(entry.line) "
hline = string(""^(start_column-length(entry_label)-length(bb_guard_rail)+max_depth-i), "")
printstyled(io, string(entry_label, hline), "\n"; color=:light_black)
bb_guard_rail = bb_guard_rail_cont
floop = false
end
end
printstyled(io, "\e[$(start_column)G$(rail)\e[1G", color = :light_black)
Expand Down Expand Up @@ -602,7 +604,6 @@ function show_ir(io::IO, code::IRCode, expr_type_printer=default_expr_type_print
if idx == last(bbrange)
print_sep = true
end
floop = true
# print new nodes first in the right position
while perm_idx <= length(new_nodes_perm)
node_idx = new_nodes_perm[perm_idx]
Expand Down
6 changes: 6 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,12 @@ let src = code_typed(my_fun28173, (Int,), debuginfo=:source)[1][1]
@test pop!(lines2) == "\$(QuoteNode(4))"
@test pop!(lines2) == "17 │ \$(QuoteNode(3))" # TODO: this should print after the next statement
@test lines1 == lines2

# verbose linetable
io = IOBuffer()
Base.IRShow.show_ir(io, ir; verbose_linetable=true)
seekstart(io)
@test count(contains(r"my_fun28173 at none:\d+"), eachline(io)) == 9
end

# Verify that extra instructions at the end of the IR
Expand Down

0 comments on commit 9e35ded

Please sign in to comment.