Skip to content

Commit

Permalink
rename is_concrete_eval_eligible utility query to is_foldable (#4…
Browse files Browse the repository at this point in the history
…5615)

`is_foldable` should be more aligned with `Base.@assume_effects`.
This should be backported to 1.8 also.
  • Loading branch information
aviatesk committed Jun 9, 2022
1 parent 087ba27 commit 43df1f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ function concrete_eval_eligible(interp::AbstractInterpreter,
isoverlayed(method_table(interp)) && !is_nonoverlayed(result.edge_effects) && return false
return f !== nothing &&
result.edge !== nothing &&
is_concrete_eval_eligible(result.edge_effects) &&
is_foldable(result.edge_effects) &&
is_all_const_arg(arginfo)
end

Expand Down
4 changes: 2 additions & 2 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ is_nothrow(effects::Effects) = effects.nothrow === ALWAYS_TRUE
is_terminates(effects::Effects) = effects.terminates === ALWAYS_TRUE
is_nonoverlayed(effects::Effects) = effects.nonoverlayed

is_concrete_eval_eligible(effects::Effects) =
is_foldable(effects::Effects) =
is_consistent(effects) &&
is_effect_free(effects) &&
is_terminates(effects)

is_total(effects::Effects) =
is_concrete_eval_eligible(effects) &&
is_foldable(effects) &&
is_nothrow(effects)

is_removable_if_unused(effects::Effects) =
Expand Down
4 changes: 2 additions & 2 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4086,14 +4086,14 @@ function entry_to_be_invalidated(c)
end
@test Base.infer_effects((Char,)) do x
entry_to_be_invalidated(x)
end |> Core.Compiler.is_concrete_eval_eligible
end |> Core.Compiler.is_foldable
@test fully_eliminated(; retval=97) do
entry_to_be_invalidated('a')
end
getcharid(c) = CONST_DICT[c] # now this is not eligible for concrete evaluation
@test Base.infer_effects((Char,)) do x
entry_to_be_invalidated(x)
end |> !Core.Compiler.is_concrete_eval_eligible
end |> !Core.Compiler.is_foldable
@test !fully_eliminated() do
entry_to_be_invalidated('a')
end

0 comments on commit 43df1f4

Please sign in to comment.