Skip to content
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

code_warntype now shows unstable SSA useref values in red #54441

Closed
wants to merge 0 commits into from

Conversation

arhik
Copy link
Sponsor

@arhik arhik commented May 11, 2024

Addresses #54028

Only function calls are covered. Other nodes like return, phi etc are not covered.

image

@arhik
Copy link
Sponsor Author

arhik commented May 11, 2024

Not full work. Just want to have a quick feedback on the output and code changes.

@arhik
Copy link
Sponsor Author

arhik commented May 11, 2024

Preview of work on Pi, Upsilon, Phi, PhiC, GotoIfNot, ReturnNodes.
image

@arhik
Copy link
Sponsor Author

arhik commented May 11, 2024

source code for above output

using Revise
using Debugger
Revise.track(Core.Compiler)

function goo(t, w)
	return sum(t) + w
end

function foo(x, z)
	y = x[1] + goo(x, z)
	return goo([sin(y), sin(z)], z)
end

code_warntype(foo, (Vector{Any}, Int), optimize=true)

print_stmt(io, idx, stmt, used, BitSet(), maxlength_idx, color, show_type)
end

function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, unstable_ssa::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool)
Copy link
Contributor

@Zentrik Zentrik May 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid having two definitions to forward when no unstable_ssa is passed, can you not just do

function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool, unstable_ssa::BitSet=BitSet())

I haven't looked at this in much detail so perhaps I missed why that won't work.

Ditto for the other functions where you do the same thing.

Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats how I started initially. Then I ran into stack overflow issues very often at multiple locations. In interest of time, I had to plant this variation in signature to bypass those issues. I might have to take a look at that approach again since I have a better idea of this work now than when I started.

Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also learnt just today that optional arguments and kwargs are different. optional arguments generate method instances with/without an optional argument. That might explain stack overflow issues I had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants