@@ -7,17 +7,19 @@ struct MICallInfo <: CallInfo
77 mi:: MethodInstance
88 rt
99 effects:: Effects
10- function MICallInfo (mi:: MethodInstance , @nospecialize (rt), effects)
10+ exct
11+ function MICallInfo (mi:: MethodInstance , @nospecialize (rt), effects, @nospecialize (exct= nothing ))
1112 if isa (rt, LimitedAccuracy)
12- return LimitedCallInfo (new (mi, ignorelimited (rt), effects))
13+ return LimitedCallInfo (new (mi, ignorelimited (rt), effects, exct ))
1314 else
14- return new (mi, rt, effects)
15+ return new (mi, rt, effects, exct )
1516 end
1617 end
1718end
1819get_mi (ci:: MICallInfo ) = ci. mi
19- get_rt (ci:: CallInfo ) = ci. rt
20+ get_rt (ci:: MICallInfo ) = ci. rt
2021get_effects (ci:: MICallInfo ) = ci. effects
22+ get_exct (ci:: MICallInfo ) = ci. exct
2123
2224abstract type WrappedCallInfo <: CallInfo end
2325
@@ -27,6 +29,7 @@ ignorewrappers(ci::WrappedCallInfo) = ignorewrappers(get_wrapped(ci))
2729get_mi (ci:: WrappedCallInfo ) = get_mi (ignorewrappers (ci))
2830get_rt (ci:: WrappedCallInfo ) = get_rt (ignorewrappers (ci))
2931get_effects (ci:: WrappedCallInfo ) = get_effects (ignorewrappers (ci))
32+ get_exct (ci:: WrappedCallInfo ) = get_exct (ignorewrappers (ci))
3033
3134# only appears when inspecting pre-optimization states
3235struct LimitedCallInfo <: WrappedCallInfo
@@ -38,9 +41,12 @@ struct RTCallInfo <: CallInfo
3841 f
3942 argtyps
4043 rt
44+ exct
4145end
46+ get_rt (ci:: RTCallInfo ) = ci. rt
4247get_mi (ci:: RTCallInfo ) = nothing
4348get_effects (ci:: RTCallInfo ) = Effects ()
49+ get_exct (ci:: RTCallInfo ) = ci. exct
4450
4551# uncached callsite, we can't recurse into this call
4652struct UncachedCallInfo <: WrappedCallInfo
5662get_mi (:: PureCallInfo ) = nothing
5763get_rt (pci:: PureCallInfo ) = pci. rt
5864get_effects (:: PureCallInfo ) = EFFECTS_TOTAL
65+ get_exct (:: PureCallInfo ) = Union{}
5966
6067# Failed
6168struct FailedCallInfo <: CallInfo
@@ -64,7 +71,8 @@ struct FailedCallInfo <: CallInfo
6471end
6572get_mi (ci:: FailedCallInfo ) = fail (ci)
6673get_rt (ci:: FailedCallInfo ) = fail (ci)
67- get_effects (ci:: FailedCallInfo ) = Effects ()
74+ get_effects (ci:: FailedCallInfo ) = fail (ci)
75+ get_exct (ci:: FailedCallInfo ) = fail (ci)
6876function fail (ci:: FailedCallInfo )
6977 @warn " MethodInstance extraction failed." ci. sig ci. rt
7078 return nothing
@@ -77,7 +85,8 @@ struct GeneratedCallInfo <: CallInfo
7785end
7886get_mi (genci:: GeneratedCallInfo ) = fail (genci)
7987get_rt (genci:: GeneratedCallInfo ) = fail (genci)
80- get_effects (genci:: GeneratedCallInfo ) = Effects ()
88+ get_effects (genci:: GeneratedCallInfo ) = fail (genci)
89+ get_exct (genci:: GeneratedCallInfo ) = fail (genci)
8190function fail (genci:: GeneratedCallInfo )
8291 @warn " Can't extract MethodInstance from call to generated functions." genci. sig genci. rt
8392 return nothing
8695struct MultiCallInfo <: CallInfo
8796 sig
8897 rt
98+ exct
8999 callinfos:: Vector{CallInfo}
100+ MultiCallInfo (@nospecialize (sig), @nospecialize (rt), callinfos:: Vector{CallInfo} ,
101+ @nospecialize (exct= nothing )) =
102+ new (sig, rt, exct, callinfos)
90103end
91- # actual code-error
92104get_mi (ci:: MultiCallInfo ) = error (" Can't extract MethodInstance from multiple call informations" )
105+ get_rt (ci:: MultiCallInfo ) = ci. rt
93106get_effects (mci:: MultiCallInfo ) = mapreduce (get_effects, CC. merge_effects, mci. callinfos)
107+ get_exct (ci:: MultiCallInfo ) = ci. exct
94108
95109struct TaskCallInfo <: CallInfo
96110 ci:: CallInfo
97111end
98112get_mi (tci:: TaskCallInfo ) = get_mi (tci. ci)
99113get_rt (tci:: TaskCallInfo ) = get_rt (tci. ci)
100114get_effects (tci:: TaskCallInfo ) = get_effects (tci. ci)
115+ get_exct (tci:: TaskCallInfo ) = get_exct (tci. ci)
101116
102117struct InvokeCallInfo <: CallInfo
103118 ci:: CallInfo
106121get_mi (ici:: InvokeCallInfo ) = get_mi (ici. ci)
107122get_rt (ici:: InvokeCallInfo ) = get_rt (ici. ci)
108123get_effects (ici:: InvokeCallInfo ) = get_effects (ici. ci)
124+ get_exct (ici:: InvokeCallInfo ) = get_exct (ici. ci)
109125
110126# OpaqueClosure CallInfo
111127struct OCCallInfo <: CallInfo
115131get_mi (occi:: OCCallInfo ) = get_mi (occi. ci)
116132get_rt (occi:: OCCallInfo ) = get_rt (occi. ci)
117133get_effects (occi:: OCCallInfo ) = get_effects (occi. ci)
134+ get_exct (occi:: OCCallInfo ) = get_exct (occi. ci)
118135
119136# Special handling for ReturnTypeCall
120137struct ReturnTypeCallInfo <: CallInfo
123140get_mi ((; vmi):: ReturnTypeCallInfo ) = isa (vmi, FailedCallInfo) ? nothing : get_mi (vmi)
124141get_rt ((; vmi):: ReturnTypeCallInfo ) = Type{isa (vmi, FailedCallInfo) ? Union{} : widenconst (get_rt (vmi))}
125142get_effects (:: ReturnTypeCallInfo ) = EFFECTS_TOTAL
143+ get_exct (:: ReturnTypeCallInfo ) = Union{} # FIXME
126144
127145struct ConstPropCallInfo <: CallInfo
128146 mi:: CallInfo
131149get_mi (cpci:: ConstPropCallInfo ) = cpci. result. linfo
132150get_rt (cpci:: ConstPropCallInfo ) = get_rt (cpci. mi)
133151get_effects (cpci:: ConstPropCallInfo ) = get_effects (cpci. result)
152+ get_exct (cpci:: ConstPropCallInfo ) = get_exct (cpci. mi)
134153
135154struct ConcreteCallInfo <: CallInfo
136155 mi:: CallInfo
139158get_mi (ceci:: ConcreteCallInfo ) = get_mi (ceci. mi)
140159get_rt (ceci:: ConcreteCallInfo ) = get_rt (ceci. mi)
141160get_effects (ceci:: ConcreteCallInfo ) = get_effects (ceci. mi)
161+ get_exct (cici:: ConcreteCallInfo ) = get_exct (ceci. mi)
142162
143163struct SemiConcreteCallInfo <: CallInfo
144164 mi:: CallInfo
147167get_mi (scci:: SemiConcreteCallInfo ) = get_mi (scci. mi)
148168get_rt (scci:: SemiConcreteCallInfo ) = get_rt (scci. mi)
149169get_effects (scci:: SemiConcreteCallInfo ) = get_effects (scci. mi)
170+ get_exct (scci:: SemiConcreteCallInfo ) = get_exct (scci. mi)
150171
151172# CUDA callsite
152173struct CuCallInfo <: CallInfo
@@ -187,22 +208,22 @@ function headstring(@nospecialize(T))
187208 end
188209end
189210
190- function __show_limited (limiter, name, tt, @nospecialize (rt), effects)
211+ function __show_limited (limiter, name, tt, @nospecialize (rt), effects, @nospecialize (exct = nothing ) )
191212 vastring (@nospecialize (T)) = (isvarargtype (T) ? headstring (T)* " ..." : string (T):: String )
192213
193214 # If effects are explicitly turned on, make sure to print them, even
194215 # if there otherwise isn't space for them, since the effects are the
195216 # most important piece of information if turned on.
196217 with_effects = get (limiter, :with_effects , false ):: Bool
218+ exception_type = get (limiter, :exception_type , false ):: Bool && exct != = nothing
197219
198- if with_effects
199- limiter. width += textwidth (repr (effects)) + 1
200- end
201-
220+ with_effects && (limiter. width += textwidth (repr (effects)) + 1 )
221+ exception_type && (limiter. width += textwidth (string (exct)) + 1 )
202222 if ! has_space (limiter, name)
203223 print (limiter, ' …' )
204224 @goto print_effects
205225 end
226+
206227 print (limiter, string (name))
207228 pstrings = String[vastring (T) for T in tt]
208229 headstrings = String[
@@ -234,15 +255,24 @@ function __show_limited(limiter, name, tt, @nospecialize(rt), effects)
234255 print (limiter, " ::…" )
235256 end
236257
237- @label print_effects
258+ @label print_effects
238259 if with_effects
239260 # Print effects unlimited
240261 print (limiter. io, " " , effects)
241262 end
263+ if exception_type
264+ print (limiter. io, ' ' )
265+ print_exct (limiter. io, exct)
266+ end
242267
243268 return nothing
244269end
245270
271+ function print_exct (io:: IO , @nospecialize (exct))
272+ color = exct === Union{} ? :green : :yellow
273+ printstyled (io, " (↑::" , exct, " )" ; color)
274+ end
275+
246276function show_callinfo (limiter, mici:: MICallInfo )
247277 mi = mici. mi
248278 tt = (Base. unwrap_unionall (mi. specTypes):: DataType ). parameters[2 : end ]
@@ -252,7 +282,8 @@ function show_callinfo(limiter, mici::MICallInfo)
252282 name = mi. def. name
253283 end
254284 rt = get_rt (mici)
255- __show_limited (limiter, name, tt, rt, get_effects (mici))
285+ exct = get_exct (mici)
286+ __show_limited (limiter, name, tt, rt, get_effects (mici), exct)
256287end
257288
258289function show_callinfo (limiter, ci:: Union{MultiCallInfo, FailedCallInfo, GeneratedCallInfo} )
0 commit comments