Skip to content

Commit

Permalink
Update show.jl
Browse files Browse the repository at this point in the history
addressing JuliaLang#54028
  • Loading branch information
arhik committed Apr 28, 2024
1 parent 6023ad6 commit 1845b27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions base/compiler/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Base.show(io::IO, cfg::CFG)
end
end

function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool)
function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool, emphasize_stmt::Bool)
if idx in used
idx_s = string(idx)
pad = " "^(maxlength_idx - length(idx_s) + 1)
Expand Down Expand Up @@ -80,6 +80,9 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxleng
elseif stmt isa GotoIfNot
show_unquoted_gotoifnot(io, stmt, indent, "#")
# everything else in the IR, defer to the generic AST printer
elseif (isa(stmt, Expr) || isa(stmt, Symbol)) && emphasize_stmt
printstyled(io, "$stmt", color=Base.error_color())
#Base.emphasize(io, "$stmt", Base.warn_color())
else
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0)
end
Expand Down Expand Up @@ -722,7 +725,8 @@ function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact},
stmt = statement_indices_to_labels(stmt, cfg)
end
show_type = type !== nothing && should_print_ssa_type(stmt)
print_stmt(io, idx, stmt, used, maxlength_idx, true, show_type)
emphasize_stmt = isa(type, Type) && (!Base.isdispatchelem(type) || type == Core.Box)
print_stmt(io, idx, stmt, used, maxlength_idx, true, show_type, emphasize_stmt)
if type !== nothing # ignore types for pre-inference code
if type === UNDEF
# This is an error, but can happen if passes don't update their type information
Expand Down

0 comments on commit 1845b27

Please sign in to comment.