Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Dec 9, 2020
1 parent d9e7202 commit fddd472
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions patches/abstract_call_gf_by_type.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/patches/abstract_call_gf_by_type.jl b/patches/abstract_call_gf_by_type.jl
index 6cf261d..3f3fb8a 100644
index e3e1e2b..384419d 100644
--- a/patches/abstract_call_gf_by_type.jl
+++ b/patches/abstract_call_gf_by_type.jl
@@ -1,6 +1,6 @@
Expand Down Expand Up @@ -69,7 +69,7 @@ index 6cf261d..3f3fb8a 100644
end
else
this_rt, edgecycle1, edge = abstract_call_method(interp, method, sig, match.sparams, multiple_matches, sv)
@@ -125,12 +146,22 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
@@ -125,13 +146,23 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
end
seen += 1
rettype = tmerge(rettype, this_rt)
Expand All @@ -87,9 +87,10 @@ index 6cf261d..3f3fb8a 100644
# try constant propagation if only 1 method is inferred to non-Bottom
# this is in preparation for inlining, or improving the return result
is_unused = call_result_unused(sv)
- if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) && isa(rettype, Type) && InferenceParams(interp).ipo_constant_propagation
+ #=== abstract_call_gf_by_type patch point 4-3 start ===#
+ if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) && (isa(rettype, Type) || has_been_reported) && InferenceParams(interp).ipo_constant_propagation
if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) &&
- is_improvable(rettype) && InferenceParams(interp).ipo_constant_propagation
+ (is_improvable(rettype) || has_been_reported) && InferenceParams(interp).ipo_constant_propagation
+ #=== abstract_call_gf_by_type patch point 4-3 end ===#
# if there's a possibility we could constant-propagate a better result
# (hopefully without doing too much work), try to do that now
Expand Down
5 changes: 3 additions & 2 deletions patches/abstract_call_gf_by_type.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://github.com/JuliaLang/julia/blob/b166d0d15f616f4a025ac5905a115399cc932ddc/base/compiler/abstractinterpretation.jl#L20-L184
# https://github.com/JuliaLang/julia/blob/5e048f3e537387fd388a5360ce6163c8f7c61ccf/base/compiler/abstractinterpretation.jl#L31-L196

function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f), argtypes::Vector{Any}, @nospecialize(atype), sv::InferenceState,
max_methods::Int = InferenceParams(interp).MAX_METHODS)
Expand Down Expand Up @@ -130,7 +130,8 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
# try constant propagation if only 1 method is inferred to non-Bottom
# this is in preparation for inlining, or improving the return result
is_unused = call_result_unused(sv)
if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) && isa(rettype, Type) && InferenceParams(interp).ipo_constant_propagation
if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) &&
is_improvable(rettype) && InferenceParams(interp).ipo_constant_propagation
# if there's a possibility we could constant-propagate a better result
# (hopefully without doing too much work), try to do that now
# TODO: it feels like this could be better integrated into abstract_call_method / typeinf_edge
Expand Down
3 changes: 2 additions & 1 deletion src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ function abstract_call_gf_by_type(interp::$(JETInterpreter), @nospecialize(f), a
# this is in preparation for inlining, or improving the return result
is_unused = call_result_unused(sv)
#=== abstract_call_gf_by_type patch point 4-3 start ===#
if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) && (isa(rettype, Type) || has_been_reported) && InferenceParams(interp).ipo_constant_propagation
if nonbot > 0 && seen == napplicable && (!edgecycle || !is_unused) &&
(is_improvable(rettype) || has_been_reported) && InferenceParams(interp).ipo_constant_propagation
#=== abstract_call_gf_by_type patch point 4-3 end ===#
# if there's a possibility we could constant-propagate a better result
# (hopefully without doing too much work), try to do that now
Expand Down

0 comments on commit fddd472

Please sign in to comment.