Skip to content

Commit 22534b4

Browse files
committed
remove several unnecessary special-case inliners
the general inliner is better and also respects effect_free (related to #9765, although none of these specific cases were mentioned there)
1 parent 0fed1b5 commit 22534b4

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

base/inference.jl

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,36 +3516,19 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
35163516
# typeassert(x::S, T) => x, when S<:T
35173517
if isType(atypes[3]) && isleaftype(atypes[3]) &&
35183518
atypes[2] atypes[3].parameters[1]
3519-
return (argexprs[2],())
3519+
return (argexprs[2], ())
35203520
end
35213521
end
35223522
topmod = _topmod(sv)
35233523
# special-case inliners for known pure functions that compute types
35243524
if sv.params.inlining
35253525
if isa(e.typ, Const) # || isconstType(e.typ)
3526-
# XXX: this is needlessly buggy and should just call `inline_as_constant`
35273526
if (f === apply_type || f === fieldtype || f === typeof ||
35283527
istopfunction(topmod, f, :typejoin) ||
3529-
istopfunction(topmod, f, :promote_type))
3530-
# XXX: compute effect_free for the actual arguments
3531-
if length(argexprs) < 2 || effect_free(argexprs[2], sv.src, sv.mod, true)
3532-
return (e.typ.val, ())
3533-
else
3534-
return (e.typ.val, Any[argexprs[2]])
3535-
end
3536-
end
3537-
end
3538-
if istopfunction(topmod, f, :isbits) && length(atypes)==2 && isType(atypes[2]) &&
3539-
effect_free(argexprs[2], sv.src, sv.mod, true) && isleaftype(atypes[2].parameters[1])
3540-
# TODO: this is needlessly complicated and should just call `inline_as_constant`
3541-
return (isbits(atypes[2].parameters[1]),())
3542-
end
3543-
if f === Core.kwfunc && length(argexprs) == 2 && isa(e.typ, Const)
3544-
# TODO: replace with a call to `inline_as_constant`
3545-
if effect_free(argexprs[2], sv.src, sv.mod, true)
3546-
return (e.typ.val, ())
3547-
else
3548-
return (e.typ.val, Any[argexprs[2]])
3528+
istopfunction(topmod, f, :isbits) ||
3529+
istopfunction(topmod, f, :promote_type) ||
3530+
(f === Core.kwfunc && length(argexprs) == 2))
3531+
return inline_as_constant(e.typ.val, argexprs, sv, nothing)
35493532
end
35503533
end
35513534
end

0 commit comments

Comments
 (0)