Skip to content

Commit

Permalink
Add a few missing effects taints (#44125)
Browse files Browse the repository at this point in the history
Should fix Downloads test (it decided Downloads' easy_hook
didn't do anything and accidentally deleted it).
  • Loading branch information
Keno committed Feb 11, 2022
1 parent 5cb0f14 commit a557536
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
14 changes: 13 additions & 1 deletion base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1482,8 +1482,17 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
if f === _apply_iterate
return abstract_apply(interp, argtypes, sv, max_methods)
elseif f === invoke
return abstract_invoke(interp, arginfo, sv)
call = abstract_invoke(interp, arginfo, sv)
if call.info === false
if call.rt === Bottom
tristate_merge!(sv, Effects(EFFECTS_TOTAL, nothrow=ALWAYS_FALSE))
else
tristate_merge!(sv, Effects())
end
end
return call
elseif f === modifyfield!
tristate_merge!(sv, Effects()) # TODO
return abstract_modifyfield!(interp, argtypes, sv)
end
rt = abstract_call_builtin(interp, f, arginfo, sv, max_methods)
Expand Down Expand Up @@ -1622,13 +1631,16 @@ function abstract_call(interp::AbstractInterpreter, arginfo::ArgInfo,
if isa(ft, PartialOpaque)
newargtypes = copy(argtypes)
newargtypes[1] = ft.env
tristate_merge!(sv, Effects()) # TODO
return abstract_call_opaque_closure(interp, ft, ArgInfo(arginfo.fargs, newargtypes), sv)
elseif (uft = unwrap_unionall(widenconst(ft)); isa(uft, DataType) && uft.name === typename(Core.OpaqueClosure))
tristate_merge!(sv, Effects()) # TODO
return CallMeta(rewrap_unionall((uft::DataType).parameters[2], widenconst(ft)), false)
elseif f === nothing
# non-constant function, but the number of arguments is known
# and the ft is not a Builtin or IntrinsicFunction
if hasintersect(widenconst(ft), Union{Builtin, Core.OpaqueClosure})
tristate_merge!(sv, Effects())
add_remark!(interp, sv, "Could not identify method table for call")
return CallMeta(Any, false)
end
Expand Down
10 changes: 10 additions & 0 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1045,3 +1045,13 @@ function call_call_ambig(b::Bool)
return 1
end
@test !fully_eliminated(call_call_ambig, Tuple{Bool})

# Test that a missing methtable identification gets tainted
# appropriately
struct FCallback; f::Union{Nothing, Function}; end
f_invoke_callback(fc) = let f=fc.f; (f !== nothing && f(); nothing); end
function f_call_invoke_callback(f::FCallback)
f_invoke_callback(f)
return nothing
end
@test !fully_eliminated(f_call_invoke_callback, Tuple{FCallback})

0 comments on commit a557536

Please sign in to comment.