-
-
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
fix recursion detection in constant prop #36148
Conversation
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.
Ah, right, I'd completely forgotten that the reason I had been avoiding this was due to the lack of a type-complexity limit. I'm somewhat confused though why this doesn't break the other test though.
# if there might be a cycle, check to make sure we don't end up | ||
# calling ourselves here. | ||
infstate = sv | ||
while !(infstate === nothing) | ||
if method === infstate.linfo.def | ||
return Any | ||
end | ||
infstate = infstate.parent | ||
end |
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 there might be a cycle, check to make sure we don't end up | |
# calling ourselves here. | |
infstate = sv | |
while !(infstate === nothing) | |
if method === infstate.linfo.def | |
return Any | |
end | |
infstate = infstate.parent | |
end | |
# if edgecycle is true, then there is a cycle and we're calling ourself | |
return Any |
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.
Well, that would just revert the original PR. What we need is to find out if adding the constant information breaks the cycle. Maybe we could do a full recursion check, but only look for other frames coming from constant prop?
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.
Okay, right we could probably make edgecycle
computation more lenient to allow one identical parent to have the constant-prop flag set and still be good here.
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.
What is the best way to check that flag? any(result.overridden_by_const)
?
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.
Sounds about right
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.
Ah, right, I'd completely forgotten that the reason I had been avoiding this was due to the lack of a recursion type-complexity limit. I'm somewhat confused though why this doesn't break the other test though, but I think it's because it's only looking through a subset of the parents (some of the parents are in the callers_in_cycle
array, and checking both I think is equivalent to returning unconditionally here)
I tried it, and that is correct as far as I can tell. |
3992115
to
9761245
Compare
#36058 was a bit too optimistic, and caused the inference stack overflow found here: JuliaGraphics/Gtk.jl#512 (comment)
This extra check fixes it while allowing the case in #36058 to still work.