Skip to content

Commit

Permalink
effects: audit EFFECTS_UNKNOWN usages (JuliaLang#50106)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jun 9, 2023
1 parent d041162 commit 43d7f88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ function abstract_call_unionall(interp::AbstractInterpreter, argtypes::Vector{An
ret = canconst ? Const(body) : Type{body}
return CallMeta(ret, Effects(EFFECTS_TOTAL; nothrow), NoCallInfo())
end
return CallMeta(Any, EFFECTS_UNKNOWN, NoCallInfo())
return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
end

function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgInfo, si::StmtInfo, sv::AbsIntState)
Expand Down Expand Up @@ -1987,7 +1987,7 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
elseif f === TypeVar
# Manually look through the definition of TypeVar to
# make sure to be able to get `PartialTypeVar`s out.
(la < 2 || la > 4) && return CallMeta(Union{}, EFFECTS_UNKNOWN, NoCallInfo())
(la < 2 || la > 4) && return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
n = argtypes[2]
ub_var = Const(Any)
lb_var = Const(Union{})
Expand Down Expand Up @@ -2301,7 +2301,7 @@ end

function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtypes::Union{VarTable,Nothing},
sv::AbsIntState)
effects = EFFECTS_UNKNOWN
effects = Effects()
ehead = e.head
𝕃ᵢ = typeinf_lattice(interp)
= (𝕃ᵢ)
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const INACCESSIBLEMEM_OR_ARGMEMONLY = 0x01 << 1

const EFFECTS_TOTAL = Effects(ALWAYS_TRUE, ALWAYS_TRUE, true, true, true, ALWAYS_TRUE, true, true)
const EFFECTS_THROWS = Effects(ALWAYS_TRUE, ALWAYS_TRUE, false, true, true, ALWAYS_TRUE, true, true)
const EFFECTS_UNKNOWN = Effects(ALWAYS_FALSE, ALWAYS_FALSE, false, false, false, ALWAYS_FALSE, true, false) # unknown mostly, but it's not overlayed at least (e.g. it's not a call)
const EFFECTS_UNKNOWN = Effects(ALWAYS_FALSE, ALWAYS_FALSE, false, false, false, ALWAYS_FALSE, true, true) # unknown mostly, but it's not overlayed and noinbounds at least (e.g. it's not a call)
const _EFFECTS_UNKNOWN = Effects(ALWAYS_FALSE, ALWAYS_FALSE, false, false, false, ALWAYS_FALSE, false, false) # unknown really

function Effects(e::Effects = _EFFECTS_UNKNOWN;
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ function abstract_modifyfield!(interp::AbstractInterpreter, argtypes::Vector{Any
nargs = length(argtypes)
if !isempty(argtypes) && isvarargtype(argtypes[nargs])
nargs - 1 <= 6 || return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
nargs > 3 || return CallMeta(Any, EFFECTS_UNKNOWN, NoCallInfo())
nargs > 3 || return CallMeta(Any, Effects(), NoCallInfo())
else
5 <= nargs <= 6 || return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
end
Expand Down Expand Up @@ -2681,7 +2681,7 @@ end
# a simplified model of abstract_call_gf_by_type for applicable
function abstract_applicable(interp::AbstractInterpreter, argtypes::Vector{Any},
sv::AbsIntState, max_methods::Int)
length(argtypes) < 2 && return CallMeta(Union{}, EFFECTS_UNKNOWN, NoCallInfo())
length(argtypes) < 2 && return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
isvarargtype(argtypes[2]) && return CallMeta(Bool, EFFECTS_UNKNOWN, NoCallInfo())
argtypes = argtypes[2:end]
atype = argtypes_to_type(argtypes)
Expand Down

0 comments on commit 43d7f88

Please sign in to comment.