Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indirect checking for return_type through an extra function #26836

Merged
merged 1 commit into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
return ret
end
return Any
elseif f === return_type
elseif is_return_type(f)
rt_rt = return_type_tfunc(argtypes, vtypes, sv)
if rt_rt !== NOT_FOUND
return rt_rt
Expand Down Expand Up @@ -755,7 +755,7 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
t = pure_eval_call(f, argtypes, atype, sv)
t !== false && return t

if istopfunction(f, :typejoin) || f === return_type
if istopfunction(f, :typejoin) || is_return_type(f)
return Type # don't try to infer these function edges directly -- it won't actually come up with anything useful
end

Expand Down
1 change: 1 addition & 0 deletions base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include("options.jl")

# core operations & types
function return_type end # promotion.jl expects this to exist
is_return_type(@Core.nospecialize(f)) = f === return_type
include("promotion.jl")
include("tuple.jl")
include("pair.jl")
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ function assemble_inline_todo!(ir::IRCode, linetable::Vector{LineInfoNode}, sv::
sv.params.inlining || continue

# Special case inliners for regular functions
if late_inline_special_case!(ir, idx, stmt, atypes, f, ft) || f === return_type
if late_inline_special_case!(ir, idx, stmt, atypes, f, ft) || is_return_type(f)
continue
end

Expand Down Expand Up @@ -1061,7 +1061,7 @@ function late_inline_special_case!(ir::IRCode, idx::Int, stmt::Expr, atypes::Vec
subtype_call = Expr(:call, GlobalRef(Core, :(<:)), stmt.args[3], stmt.args[2])
ir[SSAValue(idx)] = subtype_call
return true
elseif f === return_type
elseif is_return_type(f)
if isconstType(typ)
ir[SSAValue(idx)] = quoted(typ.parameters[1])
return true
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/queries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function stmt_effect_free(@nospecialize(stmt), @nospecialize(rt), src, spvals::S
if head === :call
f = argextype(ea[1], src, spvals)
f = isa(f, Const) ? f.val : isType(f) ? f.parameters[1] : return false
f === return_type && return true
is_return_type(f) && return true
contains_is(_PURE_BUILTINS, f) && return true
contains_is(_PURE_OR_ERROR_BUILTINS, f) || return false
rt === Bottom && return false
Expand Down