Skip to content

Commit a557536

Browse files
authored
Add a few missing effects taints (#44125)
Should fix Downloads test (it decided Downloads' easy_hook didn't do anything and accidentally deleted it).
1 parent 5cb0f14 commit a557536

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,8 +1482,17 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
14821482
if f === _apply_iterate
14831483
return abstract_apply(interp, argtypes, sv, max_methods)
14841484
elseif f === invoke
1485-
return abstract_invoke(interp, arginfo, sv)
1485+
call = abstract_invoke(interp, arginfo, sv)
1486+
if call.info === false
1487+
if call.rt === Bottom
1488+
tristate_merge!(sv, Effects(EFFECTS_TOTAL, nothrow=ALWAYS_FALSE))
1489+
else
1490+
tristate_merge!(sv, Effects())
1491+
end
1492+
end
1493+
return call
14861494
elseif f === modifyfield!
1495+
tristate_merge!(sv, Effects()) # TODO
14871496
return abstract_modifyfield!(interp, argtypes, sv)
14881497
end
14891498
rt = abstract_call_builtin(interp, f, arginfo, sv, max_methods)
@@ -1622,13 +1631,16 @@ function abstract_call(interp::AbstractInterpreter, arginfo::ArgInfo,
16221631
if isa(ft, PartialOpaque)
16231632
newargtypes = copy(argtypes)
16241633
newargtypes[1] = ft.env
1634+
tristate_merge!(sv, Effects()) # TODO
16251635
return abstract_call_opaque_closure(interp, ft, ArgInfo(arginfo.fargs, newargtypes), sv)
16261636
elseif (uft = unwrap_unionall(widenconst(ft)); isa(uft, DataType) && uft.name === typename(Core.OpaqueClosure))
1637+
tristate_merge!(sv, Effects()) # TODO
16271638
return CallMeta(rewrap_unionall((uft::DataType).parameters[2], widenconst(ft)), false)
16281639
elseif f === nothing
16291640
# non-constant function, but the number of arguments is known
16301641
# and the ft is not a Builtin or IntrinsicFunction
16311642
if hasintersect(widenconst(ft), Union{Builtin, Core.OpaqueClosure})
1643+
tristate_merge!(sv, Effects())
16321644
add_remark!(interp, sv, "Could not identify method table for call")
16331645
return CallMeta(Any, false)
16341646
end

test/compiler/inline.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,3 +1045,13 @@ function call_call_ambig(b::Bool)
10451045
return 1
10461046
end
10471047
@test !fully_eliminated(call_call_ambig, Tuple{Bool})
1048+
1049+
# Test that a missing methtable identification gets tainted
1050+
# appropriately
1051+
struct FCallback; f::Union{Nothing, Function}; end
1052+
f_invoke_callback(fc) = let f=fc.f; (f !== nothing && f(); nothing); end
1053+
function f_call_invoke_callback(f::FCallback)
1054+
f_invoke_callback(f)
1055+
return nothing
1056+
end
1057+
@test !fully_eliminated(f_call_invoke_callback, Tuple{FCallback})

0 commit comments

Comments
 (0)