Skip to content

Commit

Permalink
effects: Mark _typevar CONSISTENT_IF_NOTRETURNED
Browse files Browse the repository at this point in the history
Like other mutable allocation consistency here is flow-dependent.
  • Loading branch information
Keno committed Jan 9, 2023
1 parent 60a4479 commit a90405f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,8 @@ function builtin_effects(𝕃::AbstractLattice, @nospecialize(f::Builtin), argty
effect_free = get_binding_type_effect_free(argtypes[1], argtypes[2]) ? ALWAYS_TRUE : ALWAYS_FALSE
return Effects(EFFECTS_TOTAL; effect_free)
else
consistent = contains_is(_CONSISTENT_BUILTINS, f) ? ALWAYS_TRUE : ALWAYS_FALSE
consistent = contains_is(_CONSISTENT_BUILTINS, f) ? ALWAYS_TRUE :
(f === Core._typevar) ? CONSISTENT_IF_NOTRETURNED : ALWAYS_FALSE
if f === setfield! || f === arrayset
effect_free = EFFECT_FREE_IF_INACCESSIBLEMEMONLY
elseif contains_is(_EFFECT_FREE_BUILTINS, f) || contains_is(_PURE_BUILTINS, f)
Expand Down
7 changes: 6 additions & 1 deletion test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -687,4 +687,9 @@ end |> Core.Compiler.is_total
@test Base.infer_effects(Tuple{WrapperOneField{Float64}, Symbol}) do w, s
getfield(w, s)
end |> Core.Compiler.is_foldable
@test Core.Compiler.getfield_notundefined(WrapperOneField{Float64}, Symbol)
@test Core.Compiler.getfield_notundefined(WrapperOneField{Float64}, Symbol)

# Flow-sensitive consistenct for _typevar
@test Base.infer_effects() do
return WrapperOneField == (WrapperOneField{T} where T)
end |> Core.Compiler.is_total

0 comments on commit a90405f

Please sign in to comment.