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

inference: allocate CodeInstance with inference results ASAP #54709

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Jun 6, 2024

Update the CodeInstance after optimizations with the code (if possible), but construct it early so that there will be the option of using it for edges and invoke during optimizations, without problems with cycles.

@Keno the intent is that this will let us use CodeInstance as targets for :invoke calls, as discussed in https://hackmd.io/bpLnKm48TbWP_U_PGWgEVg. It complicates the life-cycle of a CodeInstance a little bit, so I don't think we have yet fully specified the thread-safety of this and which are valid transitions here (in general, it is only legal to narrow these properties or widen the worlds), but I think that is okay to postpone.

@vtjnash vtjnash requested a review from Keno June 6, 2024 12:11
@vtjnash vtjnash added the compiler:inference Type inference label Jun 6, 2024
Update the CodeInstance after optimizations with code (if possible), but
construct it early so that there will be the option of using it for
edges and invoke during optimizations, without problems with cycles.
src/julia.h Show resolved Hide resolved
@vtjnash vtjnash added the don't squash Don't squash merge label Jun 8, 2024
src/jltypes.c Show resolved Hide resolved
Comment on lines +456 to +461
# we might have introduced a limit marker, but we should know it must be sv and other callers_in_cycle
#@assert !isempty(sv.callers_in_cycle)
# FIXME: this assert fails, appearing to indicate there is a bug in filtering this list earlier.
# In particular (during doctests for example), during inference of
# show(Base.IOContext{Base.GenericIOBuffer{Memory{UInt8}}}, Base.Multimedia.MIME{:var"text/plain"}, LinearAlgebra.BunchKaufman{Float64, Array{Float64, 2}, Array{Int64, 1}})
# we observed one of the ssavaluetypes here to be Core.Compiler.LimitedAccuracy(typ=Any, causes=Core.Compiler.IdSet(getproperty(LinearAlgebra.BunchKaufman{Float64, Array{Float64, 2}, Array{Int64, 1}}, Symbol)))
Copy link
Member

Choose a reason for hiding this comment

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

AFAIU, this assertion should be failing because of the removal of push!(frames, frame) on L239, i.e. it fails when LimitedAccuracy is introduced in cases of self-recursion. Was this an intentional change?

Copy link
Member Author

@vtjnash vtjnash Jun 10, 2024

Choose a reason for hiding this comment

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

The code at L239 seemed to have been making this accidentally pass and hiding this bug. In particular, there didn't seem to be self-recursion here (and LimitedAccuracy should not occur if there is self-recursion, typically)?

base/compiler/typeinfer.jl Show resolved Hide resolved
@vtjnash vtjnash merged commit e7d8e57 into master Jun 14, 2024
7 checks passed
@vtjnash vtjnash deleted the jn/early-codeinstance branch June 14, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference don't squash Don't squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants