-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing unstable ssa values useref values in red #55435
base: master
Are you sure you want to change the base?
Changes from all commits
f5795cd
b7256e7
4eef9ff
37c89f7
5d1fc3a
fb09c92
d8bb9ce
33706d2
b6889df
e8f9fa9
e71969a
7ed53ed
793c626
64afd0e
4c08576
c93c074
903cfaa
1996ed0
cf84e06
37ff6c9
26e3b11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,11 +31,17 @@ 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, | ||||||||||||||||||||||
unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
if idx in used | ||||||||||||||||||||||
idx_s = string(idx) | ||||||||||||||||||||||
pad = " "^(maxlength_idx - length(idx_s) + 1) | ||||||||||||||||||||||
print(io, "%", idx_s, pad, "= ") | ||||||||||||||||||||||
if unstable_ssa != nothing && idx in unstable_ssa | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
printstyled(io, "%", idx_s; color=:light_red, bold=true) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this still print correctly for green (i.e. new) nodes? Seems like it might not be respecting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, color was not used previously. I think we can remove color::Bool argument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? It's used just below this on line 44/50 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is solved, if I understood the issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when |
||||||||||||||||||||||
else | ||||||||||||||||||||||
print(io, "%", idx_s) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
print(io, pad, "= ") | ||||||||||||||||||||||
else | ||||||||||||||||||||||
print(io, " "^(maxlength_idx + 4)) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
@@ -44,7 +50,7 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxleng | |||||||||||||||||||||
if !color && stmt isa PiNode | ||||||||||||||||||||||
# when the outer context is already colored (green, for pending nodes), don't use the usual coloring printer | ||||||||||||||||||||||
print(io, "π (") | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent) | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, 0, unstable_ssa) | ||||||||||||||||||||||
print(io, ", ") | ||||||||||||||||||||||
print(io, stmt.typ) | ||||||||||||||||||||||
print(io, ")") | ||||||||||||||||||||||
|
@@ -79,22 +85,27 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxleng | |||||||||||||||||||||
show_unquoted_phinode(io, stmt, indent, "#") | ||||||||||||||||||||||
elseif stmt isa GotoIfNot | ||||||||||||||||||||||
show_unquoted_gotoifnot(io, stmt, indent, "#") | ||||||||||||||||||||||
elseif stmt isa ReturnNode | ||||||||||||||||||||||
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0, show_type ? unstable_ssa : nothing) | ||||||||||||||||||||||
# everything else in the IR, defer to the generic AST printer | ||||||||||||||||||||||
elseif stmt isa Expr | ||||||||||||||||||||||
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0, 0, show_type ? unstable_ssa : nothing) | ||||||||||||||||||||||
Comment on lines
+88
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is the |
||||||||||||||||||||||
else | ||||||||||||||||||||||
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
nothing | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
show_unquoted(io::IO, val::Argument, indent::Int, prec::Int) = show_unquoted(io, Core.SlotNumber(val.n), indent, prec) | ||||||||||||||||||||||
show_unquoted(io::IO, val::Argument, indent::Int, prec::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) = show_unquoted(io, Core.SlotNumber(val.n), indent, prec, unstable_ssa) | ||||||||||||||||||||||
|
||||||||||||||||||||||
show_unquoted(io::IO, stmt::PhiNode, indent::Int, ::Int) = show_unquoted_phinode(io, stmt, indent, "%") | ||||||||||||||||||||||
function show_unquoted_phinode(io::IO, stmt::PhiNode, indent::Int, prefix::String) | ||||||||||||||||||||||
function show_unquoted_phinode(io::IO, stmt::PhiNode, indent::Int, prefix::String, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
args = String[let | ||||||||||||||||||||||
e = stmt.edges[i] | ||||||||||||||||||||||
v = !isassigned(stmt.values, i) ? "#undef" : | ||||||||||||||||||||||
sprint(; context=io) do io′ | ||||||||||||||||||||||
show_unquoted(io′, stmt.values[i], indent) | ||||||||||||||||||||||
val = stmt.values[i] | ||||||||||||||||||||||
show_unquoted(io′, val, indent) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
"$prefix$e => $v" | ||||||||||||||||||||||
end for i in 1:length(stmt.edges) | ||||||||||||||||||||||
|
@@ -104,45 +115,55 @@ function show_unquoted_phinode(io::IO, stmt::PhiNode, indent::Int, prefix::Strin | |||||||||||||||||||||
print(io, ')') | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_unquoted(io::IO, stmt::PhiCNode, indent::Int, ::Int) | ||||||||||||||||||||||
function show_unquoted(io::IO, stmt::PhiCNode, indent::Int, prec::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
print(io, "φᶜ (") | ||||||||||||||||||||||
first = true | ||||||||||||||||||||||
for v in stmt.values | ||||||||||||||||||||||
first ? (first = false) : print(io, ", ") | ||||||||||||||||||||||
show_unquoted(io, v, indent) | ||||||||||||||||||||||
show_unquoted(io, v, indent, prec) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
print(io, ")") | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_unquoted(io::IO, stmt::PiNode, indent::Int, ::Int) | ||||||||||||||||||||||
function show_unquoted(io::IO, stmt::PiNode, indent::Int, prec::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
print(io, "π (") | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent) | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, prec, unstable_ssa) | ||||||||||||||||||||||
print(io, ", ") | ||||||||||||||||||||||
printstyled(io, stmt.typ, color=:cyan) | ||||||||||||||||||||||
print(io, ")") | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_unquoted(io::IO, stmt::UpsilonNode, indent::Int, ::Int) | ||||||||||||||||||||||
function show_unquoted(io::IO, stmt::UpsilonNode, indent::Int, prec::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
print(io, "ϒ (") | ||||||||||||||||||||||
isdefined(stmt, :val) ? | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent) : | ||||||||||||||||||||||
if isdefined(stmt, :val) | ||||||||||||||||||||||
if stmt.val isa SSAValue | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, prec, unstable_ssa) | ||||||||||||||||||||||
else | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, prec) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
else | ||||||||||||||||||||||
print(io, "#undef") | ||||||||||||||||||||||
end | ||||||||||||||||||||||
print(io, ")") | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_unquoted(io::IO, stmt::ReturnNode, indent::Int, ::Int) | ||||||||||||||||||||||
function show_unquoted(io::IO, stmt::ReturnNode, indent::Int, prec::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||||||||||||||||||||||
if !isdefined(stmt, :val) | ||||||||||||||||||||||
print(io, "unreachable") | ||||||||||||||||||||||
else | ||||||||||||||||||||||
print(io, "return ") | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent) | ||||||||||||||||||||||
if stmt.val isa SSAValue | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, prec, unstable_ssa) | ||||||||||||||||||||||
else | ||||||||||||||||||||||
show_unquoted(io, stmt.val, indent, prec) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
end | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
show_unquoted(io::IO, stmt::GotoIfNot, indent::Int, ::Int) = show_unquoted_gotoifnot(io, stmt, indent, "%") | ||||||||||||||||||||||
function show_unquoted_gotoifnot(io::IO, stmt::GotoIfNot, indent::Int, prefix::String) | ||||||||||||||||||||||
print(io, "goto ", prefix, stmt.dest, " if not ") | ||||||||||||||||||||||
show_unquoted(io, stmt.cond, indent) | ||||||||||||||||||||||
show_unquoted(io, stmt.cond, indent, 0) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function should_print_ssa_type(@nospecialize node) | ||||||||||||||||||||||
|
@@ -628,13 +649,13 @@ end | |||||||||||||||||||||
# at index `idx`. This function is repeatedly called until it returns `nothing`. | ||||||||||||||||||||||
# to iterate nodes that are to be inserted after the statement, set `attach_after=true`. | ||||||||||||||||||||||
function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, idx::Int, config::IRShowConfig, | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int; pop_new_node! = Returns(nothing), only_after::Bool=false) | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int, unstable_ssa::Union{Nothing, BitSet} = nothing; pop_new_node! = Returns(nothing), only_after::Bool=false) | ||||||||||||||||||||||
return show_ir_stmt(io, code, idx, config.line_info_preprinter, config.line_info_postprinter, | ||||||||||||||||||||||
used, cfg, bb_idx; pop_new_node!, only_after, config.bb_color) | ||||||||||||||||||||||
used, cfg, bb_idx, unstable_ssa; pop_new_node!, only_after, config.bb_color) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, idx::Int, line_info_preprinter, line_info_postprinter, | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int; pop_new_node! = Returns(nothing), only_after::Bool=false, bb_color=:light_black) | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int, unstable_ssa::Union{Nothing, BitSet} = nothing; pop_new_node! = Returns(nothing), only_after::Bool=false, bb_color=:light_black) | ||||||||||||||||||||||
stmt = _stmt(code, idx) | ||||||||||||||||||||||
type = _type(code, idx) | ||||||||||||||||||||||
max_bb_idx_size = length(string(length(cfg.blocks))) | ||||||||||||||||||||||
|
@@ -693,7 +714,7 @@ function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, | |||||||||||||||||||||
show_type = should_print_ssa_type(new_node_inst) | ||||||||||||||||||||||
let maxlength_idx=maxlength_idx, show_type=show_type | ||||||||||||||||||||||
with_output_color(:green, io) do io′ | ||||||||||||||||||||||
print_stmt(io′, node_idx, new_node_inst, used, maxlength_idx, false, show_type) | ||||||||||||||||||||||
print_stmt(io′, node_idx, new_node_inst, used, maxlength_idx, false, show_type, unstable_ssa) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -722,7 +743,7 @@ 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) | ||||||||||||||||||||||
print_stmt(io, idx, stmt, used, maxlength_idx, true, show_type, unstable_ssa) | ||||||||||||||||||||||
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 | ||||||||||||||||||||||
|
@@ -846,6 +867,12 @@ statementidx_lineinfo_printer(f, code::IRCode) = f(code.debuginfo, :var"unknown | |||||||||||||||||||||
statementidx_lineinfo_printer(f, code::CodeInfo) = f(code.debuginfo, :var"unknown scope") | ||||||||||||||||||||||
statementidx_lineinfo_printer(code) = statementidx_lineinfo_printer(DILineInfoPrinter, code) | ||||||||||||||||||||||
|
||||||||||||||||||||||
function is_unstable_ssa(code::CodeInfo, idx::Int) | ||||||||||||||||||||||
ssaType = _type(code, idx) | ||||||||||||||||||||||
is_unstable = isa(ssaType, Type) & (!Base.isdispatchelem(ssaType) || ssaType == Core.Box) | ||||||||||||||||||||||
return is_unstable | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
||||||||||||||||||||||
function stmts_used(io::IO, code::IRCode, warn_unset_entry=true) | ||||||||||||||||||||||
insts = code.stmts | ||||||||||||||||||||||
used = BitSet() | ||||||||||||||||||||||
|
@@ -881,10 +908,10 @@ end | |||||||||||||||||||||
default_config(code::CodeInfo) = IRShowConfig(statementidx_lineinfo_printer(code)) | ||||||||||||||||||||||
|
||||||||||||||||||||||
function show_ir_stmts(io::IO, ir::Union{IRCode, CodeInfo, IncrementalCompact}, inds, config::IRShowConfig, | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int; pop_new_node! = Returns(nothing)) | ||||||||||||||||||||||
used::BitSet, cfg::CFG, bb_idx::Int, unstable_ssa::Union{Nothing, BitSet} = nothing; pop_new_node! = Returns(nothing)) | ||||||||||||||||||||||
for idx in inds | ||||||||||||||||||||||
if config.should_print_stmt(ir, idx, used) | ||||||||||||||||||||||
bb_idx = show_ir_stmt(io, ir, idx, config, used, cfg, bb_idx; pop_new_node!) | ||||||||||||||||||||||
bb_idx = show_ir_stmt(io, ir, idx, config, used, cfg, bb_idx, unstable_ssa; pop_new_node!) | ||||||||||||||||||||||
elseif bb_idx <= length(cfg.blocks) && idx == cfg.blocks[bb_idx].stmts.stop | ||||||||||||||||||||||
bb_idx += 1 | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
@@ -912,9 +939,10 @@ end | |||||||||||||||||||||
function show_ir(io::IO, ci::CodeInfo, config::IRShowConfig=default_config(ci); | ||||||||||||||||||||||
pop_new_node! = Returns(nothing)) | ||||||||||||||||||||||
used = stmts_used(io, ci) | ||||||||||||||||||||||
unstable_ssa = filter(idx -> is_unstable_ssa(ci, idx), used) | ||||||||||||||||||||||
cfg = compute_basic_blocks(ci.code) | ||||||||||||||||||||||
let io = IOContext(io, :maxssaid=>length(ci.code)) | ||||||||||||||||||||||
show_ir_stmts(io, ci, 1:length(ci.code), config, used, cfg, 1; pop_new_node!) | ||||||||||||||||||||||
show_ir_stmts(io, ci, 1:length(ci.code), config, used, cfg, 1, unstable_ssa; pop_new_node!) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
finish_show_ir(io, cfg, config) | ||||||||||||||||||||||
end | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
using Core.Compiler: has_typevar | ||
using Core.Compiler: has_typevar, userefs, scan_ssa_use! | ||
|
||
function show(io::IO, ::MIME"text/plain", u::UndefInitializer) | ||
show(io, u) | ||
|
@@ -1717,7 +1717,7 @@ end | |
|
||
# show an indented list | ||
function show_list(io::IO, items, sep, indent::Int, prec::Int=0, quote_level::Int=0, enclose_operators::Bool=false, | ||
kw::Bool=false) | ||
kw::Bool=false, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
n = length(items) | ||
n == 0 && return | ||
indent += indent_width | ||
|
@@ -1736,6 +1736,8 @@ function show_list(io::IO, items, sep, indent::Int, prec::Int=0, quote_level::In | |
elseif kw && is_expr(item, :(=), 2) | ||
item = item::Expr | ||
show_unquoted_expr_fallback(io, item, indent, quote_level) | ||
elseif item isa SSAValue | ||
show_unquoted(io, item, indent, parens ? 0 : prec, unstable_ssa) | ||
else | ||
show_unquoted(io, item, indent, parens ? 0 : prec, quote_level) | ||
end | ||
|
@@ -1744,9 +1746,10 @@ function show_list(io::IO, items, sep, indent::Int, prec::Int=0, quote_level::In | |
end | ||
end | ||
# show an indented list inside the parens (op, cl) | ||
function show_enclosed_list(io::IO, op, items, sep, cl, indent, prec=0, quote_level=0, encl_ops=false, kw::Bool=false) | ||
function show_enclosed_list(io::IO, op, items, sep, cl, indent, prec=0, quote_level=0, encl_ops=false, kw::Bool=false, | ||
unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
print(io, op) | ||
show_list(io, items, sep, indent, prec, quote_level, encl_ops, kw) | ||
show_list(io, items, sep, indent, prec, quote_level, encl_ops, kw, unstable_ssa) | ||
print(io, cl) | ||
end | ||
|
||
|
@@ -1760,7 +1763,7 @@ end | |
|
||
# show a normal (non-operator) function call, e.g. f(x, y) or A[z] | ||
# kw: `=` expressions are parsed with head `kw` in this context | ||
function show_call(io::IO, head, func, func_args, indent, quote_level, kw::Bool) | ||
function show_call(io::IO, head, func, func_args, indent, quote_level, kw::Bool, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
op, cl = expr_calls[head] | ||
if (isa(func, Symbol) && func !== :(:) && !(head === :. && isoperator(func))) || | ||
(isa(func, Symbol) && !is_valid_identifier(func)) || | ||
|
@@ -1782,7 +1785,7 @@ function show_call(io::IO, head, func, func_args, indent, quote_level, kw::Bool) | |
show_list(io, (func_args[1]::Expr).args, ", ", indent, 0, quote_level, false, kw) | ||
print(io, cl) | ||
else | ||
show_enclosed_list(io, op, func_args, ", ", cl, indent, 0, quote_level, false, kw) | ||
show_enclosed_list(io, op, func_args, ", ", cl, indent, 0, quote_level, false, kw, unstable_ssa) | ||
end | ||
end | ||
|
||
|
@@ -1802,10 +1805,12 @@ end | |
|
||
## AST printing ## | ||
|
||
function show_unquoted(io::IO, val::SSAValue, ::Int, ::Int) | ||
function show_unquoted(io::IO, val::SSAValue, ::Int, ::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
if get(io, :maxssaid, typemax(Int))::Int < val.id | ||
# invalid SSAValue, print this in red for better recognition | ||
printstyled(io, "%", val.id; color=:red) | ||
elseif unstable_ssa != nothing | ||
printstyled(io, "%", val.id; color=(val.id in unstable_ssa) ? :light_red : :default, bold=val.id in unstable_ssa) | ||
else | ||
print(io, "%", val.id) | ||
end | ||
|
@@ -1827,13 +1832,21 @@ function show_globalref(io::IO, ex::GlobalRef; allow_macroname=false) | |
nothing | ||
end | ||
|
||
function show_unquoted(io::IO, ex::SlotNumber, ::Int, ::Int) | ||
function show_unquoted(io::IO, ex::SlotNumber, ::Int, ::Int, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
slotid = ex.id | ||
slotnames = get(io, :SOURCE_SLOTNAMES, false) | ||
if isa(slotnames, Vector{String}) && slotid ≤ length(slotnames) | ||
print(io, slotnames[slotid]) | ||
if unstable_ssa != nothing | ||
printstyled(io, slotnames[slotid]; color=:light_red, bold=true) | ||
else | ||
print(io, slotnames[slotid]) | ||
end | ||
else | ||
print(io, "_", slotid) | ||
if unstable_ssa != nothing | ||
print(io, "_", slotid; color=:light_red, bold=true) | ||
else | ||
print(io, "_", slotid) | ||
end | ||
end | ||
end | ||
|
||
|
@@ -1967,7 +1980,7 @@ function show_unquoted_expr_fallback(io::IO, ex::Expr, indent::Int, quote_level: | |
end | ||
|
||
# TODO: implement interpolated strings | ||
function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::Int = 0) | ||
function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::Int = 0, unstable_ssa::Union{Nothing, BitSet} = nothing) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like This makes me wonder if the |
||
head, args, nargs = ex.head, ex.args, length(ex.args) | ||
unhandled = false | ||
# dot (i.e. "x.y"), but not compact broadcast exps | ||
|
@@ -2122,9 +2135,9 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In | |
sep = func === :(:) ? "$func" : " $func " | ||
|
||
if func_prec <= prec | ||
show_enclosed_list(io, '(', func_args, sep, ')', indent, func_prec, quote_level, true) | ||
show_enclosed_list(io, '(', func_args, sep, ')', indent, func_prec, quote_level, true, false, unstable_ssa) | ||
else | ||
show_list(io, func_args, sep, indent, func_prec, quote_level, true) | ||
show_list(io, func_args, sep, indent, func_prec, quote_level, true, false, unstable_ssa) | ||
end | ||
elseif na == 1 | ||
# 1-argument call to normally-binary operator | ||
|
@@ -2134,12 +2147,12 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In | |
print(io, ")") | ||
show_enclosed_list(io, op, func_args, ", ", cl, indent, 0, quote_level) | ||
else | ||
show_call(io, head, func, func_args, indent, quote_level, true) | ||
show_call(io, head, func, func_args, indent, quote_level, true, unstable_ssa) | ||
end | ||
|
||
# normal function (i.e. "f(x,y)") | ||
else | ||
show_call(io, head, func, func_args, indent, quote_level, true) | ||
show_call(io, head, func, func_args, indent, quote_level, true, unstable_ssa) | ||
end | ||
|
||
# new expr | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the
nothing
case instead ofBitSet()
, or requiring this parameter always?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was changed due to @fingolfin's comment #54501 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. on second thought, I think this should probably not tie unstable-highlighting to
show_type
in the first placeI think we want, e.g.,
π(%26)
andreturn %10
to show the type-unstable SSA usage in red:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need @fingolfin opinion to continue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't heard back, but I still feel that every usage of the
%26
should be highlighted in red, including theπ
andreturn
statementsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w.r.t.
nothing
the pattern that I'd reach to (which I believe is compatible with @fingolfin's original request) is:but I don't think that's a requirement for merging this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi folks, I never saw the pings for me here (I get dozens and sometimes hundreds of GitHub notifications per day and it is very easy to miss something). If you want to make sure I look at something, I recommend pinging me on Slack or sending me an email.
That said, I am not even sure what I am being asked here. Looking at PR #54501 I made no comments about what parts to show in which color I think? The comment @lgoettgens links to is about a refactoring of the code that should be neutral with respect to behavior. The goal was to avoid unnecessary allocations and code duplication. The suggestion by @topolarity addresses the first point, and the second is not that important. But in any case, I agree with @topolarity that none of this is a reason to hold up the changes (I thought that I already made that clear in my comments on #54501, by stating "Left some minor and optional suggestions, feel free to ignore/disagree" ... :-) )