-
-
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?
Testing unstable ssa values useref values in red #55435
Conversation
This is partial commit which passes unstable_ssa statements to `show_ir_stmts`. Central Idea is to show/print type unstable ssa userefs in IR statements in color. To achieve that we need to modify following code segments. [*] determine unstable_ssa [*] pass unstable_ssa to `show_ir_stmts`. [ ] pass unstable_ssa to `show_ir_stmt`. [ ] pass unstable_ssa to `print_stmt` [ ] pass unstable_ssa to `show_unquoted` This PR covers second task alone
This is partial commit which passes unstable_ssa statements to `show_ir_stmts`. Central Idea is to show/print type unstable ssa userefs in IR statements in color. To achieve that we need to modify following code segments. [*] determine unstable_ssa [*] pass unstable_ssa to `show_ir_stmts`. [*] pass unstable_ssa to `show_ir_stmt`. [ ] pass unstable_ssa to `print_stmt` [ ] pass unstable_ssa to `show_unquoted` This PR covers third task alone
This is partial commit which passes unstable_ssa statements to `show_ir_stmts`. Central Idea is to show/print type unstable ssa userefs in IR statements in color. To achieve that we need to modify following code segments. [*] determine unstable_ssa [*] pass unstable_ssa to `show_ir_stmts`. [*] pass unstable_ssa to `show_ir_stmt`. [*] pass unstable_ssa to `print_stmt` [ ] pass unstable_ssa to `show_unquoted` This PR covers fourth task alone
This is partial commit which passes unstable_ssa statements to `show_ir_stmts`. Central Idea is to show/print type unstable ssa userefs in IR statements in color. To achieve that we need to modify following code segments. [*] determine unstable_ssa [*] pass unstable_ssa to `show_ir_stmts`. [*] pass unstable_ssa to `show_ir_stmt`. [*] pass unstable_ssa to `print_stmt` [*] pass unstable_ssa to `show_unquoted` This PR covers finished basic pipeline. Other ssa values appearing in nodes like `return` etc can be easily provided now.
ops like `x + y` are covered.
pass unstable_ssa to show_unquoted This is partial commit which passes unstable_ssa statements to `show_ir_stmts`. Central Idea is to show/print type unstable ssa userefs in IR statements in color. To achieve that we need to modify following code segments. [*] determine unstable_ssa [*] pass unstable_ssa to `show_ir_stmts`. [*] pass unstable_ssa to `show_ir_stmt`. [*] pass unstable_ssa to `print_stmt` [*] pass unstable_ssa to `show_unquoted` This PR covers finished basic pipeline. Other ssa values appearing in nodes like `return` etc can be easily provided now. unstable_ssa as optional in `show_unquoted` unstable ssa should be highlighted only when appropriate
… tests for unstable SSA values useref values in red
I think it's almost there but looking at it in my terminal it seems we are printing the SSA values in a slightly different colour julia/stdlib/InteractiveUtils/src/codeview.jl Lines 30 to 43 in db25494
|
…tps://github.com/joseeloren/julia into testing_unstable_SSA_values_useref_values_in_red
You are right @gbaraldi Fixed. |
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.
@@ -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) |
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 of BitSet()
, 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.
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 π
and return
statements
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.
w.r.t. nothing
the pattern that I'd reach to (which I believe is compatible with @fingolfin's original request) is:
const EMPTY_BITSET = BitSet()
function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool,
unstable_ssa::BitSet = EMPTY_BITSET)
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" ... :-) )
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 | ||
printstyled(io, "%", idx_s; color=:light_red, bold=true) |
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.
Does this still print correctly for green (i.e. new) nodes?
Seems like it might not be respecting the color::Bool
argument
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.
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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
when color === false
, this function is not supposed to print color - it looks to me that it still does
Bump @topolarity @fingolfin @gbaraldi . I think this is just waiting for some reaction from your side to the authors changes and responses to your comments in this PR and in #54501. And it would be great to get this in 1.12 (aka merged until tomorrow) |
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) |
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.
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) | |
elseif stmt isa ReturnNode | |
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0, unstable_ssa) | |
# 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, unstable_ssa) |
This is the show_type
issue I was referring to in https://github.com/JuliaLang/julia/pull/55435/files/cf84e06513b7a3e0c4aef70e3298713d638c04b7#r1721769973
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like unstable_ssa
is dropped (in this function) for a lot of possible IR statements (e.g. Expr(:tuple, ...)
)
This makes me wonder if the unstable_ssa
should be attached to an IOContext
instead of being piped manually through all of the print / show machinery
The main obstacle here seems to be the conflicts this PR has which somebody needs to resolve before merging is an option? |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
if unstable_ssa != nothing && idx in unstable_ssa | |
if color && unstable_ssa != nothing && idx in unstable_ssa |
I have made some tests to check if unstable ssa values useref values are in red. This address issue #54028 PRs: #54501 and #54441. The last one is #54501, that is waiting for these tests.
@gbaraldi