From aaa9bd977815dc910beb34f124973e1c96aabcd2 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 24 Oct 2018 17:47:22 -0400 Subject: [PATCH] inference: set limited flag on entire cycle We typically expect that all members in a cycle have the same attributes. It may not be necessary, but that is how we record and track the items in a cycle. --- base/compiler/typeinfer.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index ae842497ed216..f7dbcbea8481e 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -408,7 +408,7 @@ function union_caller_cycle!(a::InferenceState, b::InferenceState) return end -function merge_call_chain!(parent::InferenceState, ancestor::InferenceState, child::InferenceState) +function merge_call_chain!(parent::InferenceState, ancestor::InferenceState, child::InferenceState, limited::Bool) # add backedge of parent <- child # then add all backedges of parent <- parent.parent # and merge all of the callers into ancestor.callers_in_cycle @@ -420,6 +420,11 @@ function merge_call_chain!(parent::InferenceState, ancestor::InferenceState, chi parent = child.parent child === ancestor && break end + if limited + for caller in ancestor.callers_in_cycle + caller.limited = true + end + end end # Walk through `linfo`'s upstream call chain, starting at `parent`. If a parent @@ -432,17 +437,19 @@ end function resolve_call_cycle!(linfo::MethodInstance, parent::InferenceState) frame = parent uncached = false + limited = false while isa(frame, InferenceState) uncached |= !frame.cached # ensure we never add an uncached frame to a cycle + limited |= frame.limited if frame.linfo === linfo uncached && return true - merge_call_chain!(parent, frame, frame) + merge_call_chain!(parent, frame, frame, limited) return frame end for caller in frame.callers_in_cycle if caller.linfo === linfo uncached && return true - merge_call_chain!(parent, frame, caller) + merge_call_chain!(parent, frame, caller, limited) return caller end end