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

update to https://github.com/JuliaLang/julia/pull/42082 #224

Merged
merged 1 commit into from
Sep 6, 2021
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
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
version:
- 'nightly'
- '1.7-nightly'
os:
- ubuntu-latest
- macOS-latest
Expand Down
5 changes: 4 additions & 1 deletion src/Cthulhu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ function do_typeinf!(interp::CthulhuInterpreter, mi::MethodInstance)
# we may want to handle the case when `InferenceState(...)` returns `nothing`,
# which indicates code generation of a `@generated` has been failed,
# and show it in the UI in some way ?
frame = InferenceState(result, true, interp)::InferenceState
# branch on https://github.com/JuliaLang/julia/pull/42082
frame = @static hasmethod(InferenceState, (InferenceResult,Symbol,AbstractInterpreter)) ?
InferenceState(result, #=cache=# :global, interp)::InferenceState :
InferenceState(result, #=cached=# true, interp)::InferenceState
Core.Compiler.typeinf(interp, frame)
return nothing
end
Expand Down
9 changes: 8 additions & 1 deletion src/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ end

# branch on https://github.com/JuliaLang/julia/pull/41328
@static if isdefined(Compiler, :is_stmt_inline)
function Compiler.inlining_policy(interp::CthulhuInterpreter, @nospecialize(src), stmt_flag::UInt8)
Copy link
Member Author

Choose a reason for hiding this comment

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

The CIs are failing now because 1.8.0-DEV.472 doesn't seem to arrive at the nightly channel yet.
Still I'd like to drop the support for dev versions between JuliaLang/julia#41328 and 1.8.0-DEV.472.

function Compiler.inlining_policy(
interp::CthulhuInterpreter, @nospecialize(src), stmt_flag::UInt8,
mi::MethodInstance, argtypes::Vector{Any})
@assert isa(src, OptimizedSource) || isnothing(src)
if isa(src, OptimizedSource)
if Compiler.is_stmt_inline(stmt_flag) || src.isinlineable
return src.ir
end
else
# the default inlining policy may try additional effor to find the source in a local cache
return Base.@invoke Compiler.inlining_policy(
interp::AbstractInterpreter, nothing, stmt_flag::UInt8,
mi::MethodInstance, argtypes::Vector{Any})
end
return nothing
end
Expand Down
49 changes: 26 additions & 23 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,32 @@ let callsites = find_callsites_by_ftt(call_by_apply, Tuple{Tuple{Int}}; optimize
@test length(callsites) == 1
end

if Base.JLOptions().check_bounds ∈ (0, 2)
@testset "DCE & boundscheck" begin
Base.@propagate_inbounds function f(x)
@boundscheck error()
end
g(x) = @inbounds f(x)
h(x) = f(x)

(_,CI, _, _, _, _) = process(g, Tuple{Vector{Float64}})
@test all(CI.stmts.inst) do stmt
isa(stmt, Core.GotoNode) || (isa(stmt, Core.ReturnNode) && isdefined(stmt, :val)) || Base.Meta.isexpr(stmt, :code_coverage_effect, 0)
end

(_,CI, _, _, _, _) = process(h, Tuple{Vector{Float64}})
i = 1
while CI.stmts.inst[i] === nothing || Base.Meta.isexpr(CI.stmts.inst[i], :code_coverage_effect, 0)
i += 1
end
@test length(CI.stmts) - i + 1 == 2
stmt = CI.stmts.inst[end]
@test isa(stmt, Core.ReturnNode) && !isdefined(stmt, :val)
end
end
# # TODO run this testset in a separate process
# # julia --check-bounds=auto --code-coverage=none
# @testset "DCE & boundscheck" begin
# M = Module()
# @eval M begin
# Base.@propagate_inbounds function f(x)
# @boundscheck error()
# end
# g(x) = @inbounds f(x)
# h(x) = f(x)
# end
#
# let
# (_,CI, _, _, _, _) = process(M.g, Tuple{Vector{Float64}})
# @test all(CI.stmts.inst) do stmt
# isa(stmt, Core.GotoNode) || (isa(stmt, Core.ReturnNode) && isdefined(stmt, :val))
# end
# end
#
# let
# (_,CI, _, _, _, _) = process(M.h, Tuple{Vector{Float64}})
# @test count(!isnothing, CI.stmts.inst) == 2
# stmt = CI.stmts.inst[end]
# @test isa(stmt, Core.ReturnNode) && !isdefined(stmt, :val)
# end
# end
Comment on lines -102 to +127
Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out that this testset hasn't been ran so far. Running it in a separate process with --check-bounds=auto --code-coverage=none options will solve issues, but I will leave it for another PR.


# Something with many methods, but enough to be under the match limit
g_matches(a::Int, b::Int) = a+b
Expand Down