Skip to content

Commit

Permalink
fix typo, add more tests for @inline-declaration (JuliaLang#44964)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Apr 13, 2022
1 parent 322fd70 commit 5ce65ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,9 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
code = get(code_cache(interp), mi, nothing)
if code isa CodeInstance # return existing rettype if the code is already inferred
if code.inferred === nothing && is_stmt_inline(get_curr_ssaflag(caller))
# we already inferred this edge previously and decided to discarded the inferred code
# but the inlinear will request to use it, we re-infer it here and keep it around in the local cache
# we already inferred this edge before and decided to discard the inferred code,
# nevertheless we re-infer it here again and keep it around in the local cache
# since the inliner will request to use it later
cache = :local
else
effects = ipo_effects(code)
Expand Down
12 changes: 8 additions & 4 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,14 @@ f34900(x::Int, y::Int) = invoke(f34900, Tuple{Int, Any}, x, y)
@test fully_eliminated(f34900, Tuple{Int, Int}; retval=Core.Argument(2))

@testset "check jl_ir_flag_inlineable for inline macro" begin
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), first(methods(@inline x -> x)).source)
@test !ccall(:jl_ir_flag_inlineable, Bool, (Any,), first(methods( x -> x)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), first(methods(@inline function f(x) x end)).source)
@test !ccall(:jl_ir_flag_inlineable, Bool, (Any,), first(methods(function f(x) x end)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(@inline x -> x)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(x -> (@inline; x))).source)
@test !ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(x -> x)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(@inline function f(x) x end)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(function f(x) @inline; x end)).source)
@test !ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods(function f(x) x end)).source)
@test ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods() do x @inline; x end).source)
@test !ccall(:jl_ir_flag_inlineable, Bool, (Any,), only(methods() do x x end).source)
end

const _a_global_array = [1]
Expand Down

0 comments on commit 5ce65ab

Please sign in to comment.