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

prefetch JuliaLang/julia#49801 for 1.9 #514

Merged
merged 1 commit into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/analyzers/jetanalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ a package, or improve the accuracy of base abstract interpretation analysis.
# getting rid of the false positive error from `getindex((), i)`.
@overlay JET_METHOD_TABLE Base.iterate(::Tuple{}, ::Int) = nothing

# take the effects of https://github.com/JuliaLang/julia/pull/49801 for release versions
@static if VERSION < v"1.10.0-DEV.1289"
@overlay JET_METHOD_TABLE Base.@assume_effects :foldable function Base.aligned_sizeof(@nospecialize T::Type)
if isa(T, Union)
if Base.allocatedinline(T)
# NOTE this check is equivalent to `isbitsunion(T)`, we can improve type
# inference in the second branch with the outer `isa(T, Union)` check
_, sz, al = Base.uniontype_layout(T)
return Base.LLT_ALIGN(sz, al)
end
elseif Base.allocatedinline(T)
al = Base.datatype_alignment(T)
return Base.LLT_ALIGN(Core.sizeof(T), al)
end
return Core.sizeof(Ptr{Cvoid})
end
end

# overloads
# =========

Expand Down
3 changes: 3 additions & 0 deletions test/analyzers/test_jetanalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,4 +1070,7 @@ test_call(issue_404, (Bool,))
end
end

# https://github.com/JuliaLang/julia/pull/49801
test_call(Base.aligned_sizeof, (Union{DataType,Union},))

end # module test_jetanalyzer