-
Notifications
You must be signed in to change notification settings - Fork 31
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
Example where getfield does not constant fold in JET #254
Comments
It might be better to use the latest version of Cthulhu.jl to understand how constant-prop' heuristics work on your code: And I guess you're on v1.7 ? Having said that, we may want JET to constant-prop' far more aggressively so that we won't see this sort of error even on v1.7 ? |
Unfortunately I can't load JET on Julia master: julia> using JET
[ Info: Precompiling JET [c3a54625-cd67-489e-a8e7-0a5a0ff4e31b]
ERROR: LoadError: MethodError: no method matching Core.Compiler.OptimizationParams(; inlining=true, inline_cost_threshold=100, inline_nonleaf_penalty=1000, inline_tupleret_bonus=250, inline_error_path_cost=20, max_methods=3, tuple_splat=32, union_splitting=4, unoptimize_throw_blocks=true)
[ stacktrace elided ] So yeah, I'm on Julia 1.7. I'll try to use Cthulhu to dig in now. It turned out to be quite difficult to make a minimal example, probably because the |
Oh, please checkout to the latest master branch of JET. v0.4.6 isn't be compatible with the latest master. The latest master branch should work with it, and should analyze your code faster. It might be tricky to debug constant prop' stuff, so please ask me any trouble you have. |
I blundered around in the recursive calls in Chtulhu for a while and did find one of the calls where the Anyway, I tried with latest JET on Julia's master branch, and the issue was gone! Thanks - and closing as solved. |
Okay glad to know that. I may try to debug your code tomorrow if I have time. |
It's a little tricky to replicate, I'll see if I can make a smaller example. I'll try to describe what's going on so you might not need to replicate it fully.
For now, you can replicate it by checking out
TranscodingStreams.jl
commit0dedb79
(from my repo: https://github.com/jakobnissen/TranscodingStreams.jl/tree/0dedb795faceef48ce8aa5385808d4ab91d02c30), and doing the following:Here is the output:
The weird thing is at the end. Line
TranscodingStreams.jl/src/noop.jl:164
contains:As can be seen from the final line of JET's output,
buffer
is inferred to beBuffer
, which has the following layout:And
buffer.transcoded
is inferred to beUnion{Int64, Vector{UInt8}}
- but this is despite JET realizing that the symbol:transcoded
is constant. In other words, JET realizes it fetchesgetfield(::Buffer, :transcoded)
, but it does not realize that this is aInt64
?The text was updated successfully, but these errors were encountered: