@@ -3,30 +3,30 @@ using Unicode
3
3
abstract type CallInfo end
4
4
5
5
# Call could be resolved to a singular MI
6
- struct MICallInfo <: CallInfo
7
- mi :: MethodInstance
6
+ struct EdgeCallInfo <: CallInfo
7
+ edge :: CodeInstance
8
8
rt
9
9
effects:: Effects
10
10
exct
11
- function MICallInfo (mi :: MethodInstance , @nospecialize (rt), effects, @nospecialize (exct= nothing ))
11
+ function EdgeCallInfo (edge :: CodeInstance , @nospecialize (rt), effects:: Effects , @nospecialize (exct= nothing ))
12
12
if isa (rt, LimitedAccuracy)
13
- return LimitedCallInfo (new (mi , ignorelimited (rt), effects, exct))
13
+ return LimitedCallInfo (new (edge , ignorelimited (rt), effects, exct))
14
14
else
15
- return new (mi , rt, effects, exct)
15
+ return new (edge , rt, effects, exct)
16
16
end
17
17
end
18
18
end
19
- get_mi (ci:: MICallInfo ) = ci. mi
20
- get_rt (ci:: MICallInfo ) = ci. rt
21
- get_effects (ci:: MICallInfo ) = ci. effects
22
- get_exct (ci:: MICallInfo ) = ci. exct
19
+ get_ci (ci:: EdgeCallInfo ) = ci. edge
20
+ get_rt (ci:: EdgeCallInfo ) = ci. rt
21
+ get_effects (ci:: EdgeCallInfo ) = ci. effects
22
+ get_exct (ci:: EdgeCallInfo ) = ci. exct
23
23
24
24
abstract type WrappedCallInfo <: CallInfo end
25
25
26
26
get_wrapped (ci:: WrappedCallInfo ) = ci. wrapped
27
27
ignorewrappers (ci:: CallInfo ) = ci
28
28
ignorewrappers (ci:: WrappedCallInfo ) = ignorewrappers (get_wrapped (ci))
29
- get_mi (ci:: WrappedCallInfo ) = get_mi (ignorewrappers (ci))
29
+ get_ci (ci:: WrappedCallInfo ) = get_ci (ignorewrappers (ci))
30
30
get_rt (ci:: WrappedCallInfo ) = get_rt (ignorewrappers (ci))
31
31
get_effects (ci:: WrappedCallInfo ) = get_effects (ignorewrappers (ci))
32
32
get_exct (ci:: WrappedCallInfo ) = get_exct (ignorewrappers (ci))
@@ -44,22 +44,17 @@ struct RTCallInfo <: CallInfo
44
44
exct
45
45
end
46
46
get_rt (ci:: RTCallInfo ) = ci. rt
47
- get_mi (ci:: RTCallInfo ) = nothing
47
+ get_ci (ci:: RTCallInfo ) = nothing
48
48
get_effects (ci:: RTCallInfo ) = Effects ()
49
49
get_exct (ci:: RTCallInfo ) = ci. exct
50
50
51
- # uncached callsite, we can't recurse into this call
52
- struct UncachedCallInfo <: WrappedCallInfo
53
- wrapped:: CallInfo
54
- end
55
-
56
51
struct PureCallInfo <: CallInfo
57
52
argtypes:: Vector{Any}
58
53
rt
59
54
PureCallInfo (argtypes:: Vector{Any} , @nospecialize (rt)) =
60
55
new (argtypes, rt)
61
56
end
62
- get_mi (:: PureCallInfo ) = nothing
57
+ get_ci (:: PureCallInfo ) = nothing
63
58
get_rt (pci:: PureCallInfo ) = pci. rt
64
59
get_effects (:: PureCallInfo ) = EFFECTS_TOTAL
65
60
get_exct (:: PureCallInfo ) = Union{}
@@ -69,7 +64,7 @@ struct FailedCallInfo <: CallInfo
69
64
sig
70
65
rt
71
66
end
72
- get_mi (ci:: FailedCallInfo ) = fail (ci)
67
+ get_ci (ci:: FailedCallInfo ) = fail (ci)
73
68
get_rt (ci:: FailedCallInfo ) = fail (ci)
74
69
get_effects (ci:: FailedCallInfo ) = fail (ci)
75
70
get_exct (ci:: FailedCallInfo ) = fail (ci)
@@ -83,7 +78,7 @@ struct GeneratedCallInfo <: CallInfo
83
78
sig
84
79
rt
85
80
end
86
- get_mi (genci:: GeneratedCallInfo ) = fail (genci)
81
+ get_ci (genci:: GeneratedCallInfo ) = fail (genci)
87
82
get_rt (genci:: GeneratedCallInfo ) = fail (genci)
88
83
get_effects (genci:: GeneratedCallInfo ) = fail (genci)
89
84
get_exct (genci:: GeneratedCallInfo ) = fail (genci)
@@ -101,15 +96,15 @@ struct MultiCallInfo <: CallInfo
101
96
@nospecialize (exct= nothing )) =
102
97
new (sig, rt, exct, callinfos)
103
98
end
104
- get_mi (ci:: MultiCallInfo ) = error (" Can't extract MethodInstance from multiple call informations" )
99
+ get_ci (ci:: MultiCallInfo ) = error (" Can't extract MethodInstance from multiple call informations" )
105
100
get_rt (ci:: MultiCallInfo ) = ci. rt
106
101
get_effects (mci:: MultiCallInfo ) = mapreduce (get_effects, CC. merge_effects, mci. callinfos)
107
102
get_exct (ci:: MultiCallInfo ) = ci. exct
108
103
109
104
struct TaskCallInfo <: CallInfo
110
105
ci:: CallInfo
111
106
end
112
- get_mi (tci:: TaskCallInfo ) = get_mi (tci. ci)
107
+ get_ci (tci:: TaskCallInfo ) = get_ci (tci. ci)
113
108
get_rt (tci:: TaskCallInfo ) = get_rt (tci. ci)
114
109
get_effects (tci:: TaskCallInfo ) = get_effects (tci. ci)
115
110
get_exct (tci:: TaskCallInfo ) = get_exct (tci. ci)
@@ -118,7 +113,7 @@ struct InvokeCallInfo <: CallInfo
118
113
ci:: CallInfo
119
114
InvokeCallInfo (@nospecialize ci:: CallInfo ) = new (ci)
120
115
end
121
- get_mi (ici:: InvokeCallInfo ) = get_mi (ici. ci)
116
+ get_ci (ici:: InvokeCallInfo ) = get_ci (ici. ci)
122
117
get_rt (ici:: InvokeCallInfo ) = get_rt (ici. ci)
123
118
get_effects (ici:: InvokeCallInfo ) = get_effects (ici. ci)
124
119
get_exct (ici:: InvokeCallInfo ) = get_exct (ici. ci)
@@ -128,7 +123,7 @@ struct OCCallInfo <: CallInfo
128
123
ci:: CallInfo
129
124
OCCallInfo (@nospecialize ci:: CallInfo ) = new (ci)
130
125
end
131
- get_mi (occi:: OCCallInfo ) = get_mi (occi. ci)
126
+ get_ci (occi:: OCCallInfo ) = get_ci (occi. ci)
132
127
get_rt (occi:: OCCallInfo ) = get_rt (occi. ci)
133
128
get_effects (occi:: OCCallInfo ) = get_effects (occi. ci)
134
129
get_exct (occi:: OCCallInfo ) = get_exct (occi. ci)
@@ -137,52 +132,52 @@ get_exct(occi::OCCallInfo) = get_exct(occi.ci)
137
132
struct ReturnTypeCallInfo <: CallInfo
138
133
vmi:: CallInfo # virtualized method call
139
134
end
140
- get_mi ((; vmi):: ReturnTypeCallInfo ) = isa (vmi, FailedCallInfo) ? nothing : get_mi (vmi)
135
+ get_ci ((; vmi):: ReturnTypeCallInfo ) = isa (vmi, FailedCallInfo) ? nothing : get_ci (vmi)
141
136
get_rt ((; vmi):: ReturnTypeCallInfo ) = Type{isa (vmi, FailedCallInfo) ? Union{} : widenconst (get_rt (vmi))}
142
137
get_effects (:: ReturnTypeCallInfo ) = EFFECTS_TOTAL
143
138
get_exct (:: ReturnTypeCallInfo ) = Union{} # FIXME
144
139
145
140
struct ConstPropCallInfo <: CallInfo
146
- mi :: CallInfo
141
+ ci :: CallInfo
147
142
result:: InferenceResult
148
143
end
149
- get_mi (cpci:: ConstPropCallInfo ) = cpci. result . linfo
150
- get_rt (cpci:: ConstPropCallInfo ) = get_rt (cpci. mi )
144
+ get_ci (cpci:: ConstPropCallInfo ) = get_ci ( cpci. ci)
145
+ get_rt (cpci:: ConstPropCallInfo ) = get_rt (cpci. ci )
151
146
get_effects (cpci:: ConstPropCallInfo ) = get_effects (cpci. result)
152
- get_exct (cpci:: ConstPropCallInfo ) = get_exct (cpci. mi )
147
+ get_exct (cpci:: ConstPropCallInfo ) = get_exct (cpci. ci )
153
148
154
149
struct ConcreteCallInfo <: CallInfo
155
- mi :: CallInfo
150
+ ci :: CallInfo
156
151
argtypes:: ArgTypes
157
152
end
158
- get_mi (ceci:: ConcreteCallInfo ) = get_mi (ceci. mi )
159
- get_rt (ceci:: ConcreteCallInfo ) = get_rt (ceci. mi )
160
- get_effects (ceci:: ConcreteCallInfo ) = get_effects (ceci. mi )
161
- get_exct (cici:: ConcreteCallInfo ) = get_exct (ceci. mi )
153
+ get_ci (ceci:: ConcreteCallInfo ) = get_ci (ceci. ci )
154
+ get_rt (ceci:: ConcreteCallInfo ) = get_rt (ceci. ci )
155
+ get_effects (ceci:: ConcreteCallInfo ) = get_effects (ceci. ci )
156
+ get_exct (cici:: ConcreteCallInfo ) = get_exct (ceci. ci )
162
157
163
158
struct SemiConcreteCallInfo <: CallInfo
164
- mi :: CallInfo
159
+ ci :: CallInfo
165
160
ir:: IRCode
166
161
end
167
- get_mi (scci:: SemiConcreteCallInfo ) = get_mi (scci. mi )
168
- get_rt (scci:: SemiConcreteCallInfo ) = get_rt (scci. mi )
169
- get_effects (scci:: SemiConcreteCallInfo ) = get_effects (scci. mi )
170
- get_exct (scci:: SemiConcreteCallInfo ) = get_exct (scci. mi )
162
+ get_ci (scci:: SemiConcreteCallInfo ) = get_ci (scci. ci )
163
+ get_rt (scci:: SemiConcreteCallInfo ) = get_rt (scci. ci )
164
+ get_effects (scci:: SemiConcreteCallInfo ) = get_effects (scci. ci )
165
+ get_exct (scci:: SemiConcreteCallInfo ) = get_exct (scci. ci )
171
166
172
167
# CUDA callsite
173
168
struct CuCallInfo <: CallInfo
174
- cumi :: MICallInfo
169
+ ci :: EdgeCallInfo
175
170
end
176
- get_mi (gci:: CuCallInfo ) = get_mi (gci. cumi )
177
- get_rt (gci:: CuCallInfo ) = get_rt (gci. cumi )
178
- get_effects (gci:: CuCallInfo ) = get_effects (gci. cumi )
171
+ get_ci (gci:: CuCallInfo ) = get_ci (gci. ci )
172
+ get_rt (gci:: CuCallInfo ) = get_rt (gci. ci )
173
+ get_effects (gci:: CuCallInfo ) = get_effects (gci. ci )
179
174
180
175
struct Callsite
181
176
id:: Int # ssa-id
182
177
info:: CallInfo
183
178
head:: Symbol
184
179
end
185
- get_mi (c:: Callsite ) = get_mi (c. info)
180
+ get_ci (c:: Callsite ) = get_ci (c. info)
186
181
get_effects (c:: Callsite ) = get_effects (c. info)
187
182
188
183
# Callsite printing
@@ -277,17 +272,17 @@ function Base.show(io::IO, (;exct)::ExctWrapper)
277
272
printstyled (io, " (↑::" , exct, " )" ; color)
278
273
end
279
274
280
- function show_callinfo (limiter, mici :: MICallInfo )
281
- mi = mici . mi
275
+ function show_callinfo (limiter, ci :: EdgeCallInfo )
276
+ mi = ci . edge . def
282
277
tt = (Base. unwrap_unionall (mi. specTypes):: DataType ). parameters[2 : end ]
283
278
if ! isa (mi. def, Method)
284
279
name = " :toplevel"
285
280
else
286
281
name = mi. def. name
287
282
end
288
- rt = get_rt (mici )
289
- exct = get_exct (mici )
290
- __show_limited (limiter, name, tt, rt, get_effects (mici ), exct)
283
+ rt = get_rt (ci )
284
+ exct = get_exct (ci )
285
+ __show_limited (limiter, name, tt, rt, get_effects (ci ), exct)
291
286
end
292
287
293
288
function show_callinfo (limiter, ci:: Union{MultiCallInfo, FailedCallInfo, GeneratedCallInfo} )
@@ -317,20 +312,20 @@ function show_callinfo(limiter, ci::ConstPropCallInfo)
317
312
# XXX : The first argument could be const-overriden too
318
313
name = ci. result. linfo. def. name
319
314
tt = ci. result. argtypes[2 : end ]
320
- ci = ignorewrappers (ci. mi ):: MICallInfo
315
+ ci = ignorewrappers (ci. ci ):: EdgeCallInfo
321
316
__show_limited (limiter, name, tt, get_rt (ci), get_effects (ci))
322
317
end
323
318
324
319
function show_callinfo (limiter, ci:: SemiConcreteCallInfo )
325
320
# XXX : The first argument could be const-overriden too
326
- name = get_mi (ci). def. name
321
+ name = get_ci (ci). def . def. name
327
322
tt = ci. ir. argtypes[2 : end ]
328
323
__show_limited (limiter, name, tt, get_rt (ci), get_effects (ci))
329
324
end
330
325
331
326
function show_callinfo (limiter, ci:: ConcreteCallInfo )
332
327
# XXX : The first argument could be const-overriden too
333
- name = get_mi (ci). def. name
328
+ name = get_ci (ci). def . def. name
334
329
tt = ci. argtypes[2 : end ]
335
330
__show_limited (limiter, name, tt, get_rt (ci), get_effects (ci))
336
331
end
@@ -435,7 +430,7 @@ function Base.show(io::IO, c::Callsite)
435
430
limiter = TextWidthLimiter (io, cols)
436
431
limiter. width += 1 # for the '%' character
437
432
print (limiter, string (c. id))
438
- if isa (info, MICallInfo )
433
+ if isa (info, EdgeCallInfo )
439
434
print (limiter, optimize ? string (" = " , c. head, ' ' ) : " = " )
440
435
show_callinfo (limiter, info)
441
436
else
@@ -457,16 +452,15 @@ function wrapped_callinfo(limiter, ci::WrappedCallInfo)
457
452
print (limiter, " > " )
458
453
end
459
454
_wrapped_callinfo (limiter, :: LimitedCallInfo ) = print (limiter, " limited" )
460
- _wrapped_callinfo (limiter, :: UncachedCallInfo ) = print (limiter, " uncached" )
461
455
462
456
# is_callsite returns true if `call` dispatches to `callee`
463
457
# See also `maybe_callsite` below
464
- is_callsite (call:: MethodInstance , callee:: MethodInstance ) = call === callee
465
- is_callsite (:: Nothing , callee:: MethodInstance ) = false # for when `get_mi ` returns `nothing`
458
+ is_callsite (call:: CodeInstance , callee:: MethodInstance ) = call. def === callee
459
+ is_callsite (:: Nothing , callee:: MethodInstance ) = false # for when `get_ci ` returns `nothing`
466
460
467
461
# is_callsite for higher-level inputs
468
462
is_callsite (cs:: Callsite , callee:: MethodInstance ) = is_callsite (cs. info, callee)
469
- is_callsite (info:: CallInfo , callee:: MethodInstance ) = is_callsite (get_mi (info), callee)
463
+ is_callsite (info:: CallInfo , callee:: MethodInstance ) = is_callsite (get_ci (info), callee)
470
464
# special CallInfo cases:
471
465
function is_callsite (info:: MultiCallInfo , callee:: MethodInstance )
472
466
for csi in info. callinfos
477
471
478
472
# maybe_callsite returns true if `call` *might* dispatch to `callee`
479
473
# See also `is_callsite` above
480
- function maybe_callsite (call:: MethodInstance , callee:: MethodInstance )
474
+ function maybe_callsite (call:: CodeInstance , callee:: MethodInstance )
481
475
# handle comparison among Varargs
482
476
function generalized_va_subtype (@nospecialize (Tshort), @nospecialize (Tlong))
483
477
nshort, nlong = length (Tshort. parameters), length (Tlong. parameters)
@@ -492,7 +486,7 @@ function maybe_callsite(call::MethodInstance, callee::MethodInstance)
492
486
return T <: unwrapva (Tlong. parameters[end ])
493
487
end
494
488
495
- Tcall, Tcallee = call. specTypes, callee. specTypes
489
+ Tcall, Tcallee = call. def . specTypes, callee. specTypes
496
490
Tcall <: Tcallee && return true
497
491
# Make sure we handle Tcall = Tuple{Vararg{String}}, Tcallee = Tuple{String,Vararg{String}}
498
492
if Base. isvatuple (Tcall) && Base. isvatuple (Tcallee)
507
501
# maybe_callsite for higher-level inputs
508
502
maybe_callsite (cs:: Callsite , callee:: MethodInstance ) = maybe_callsite (cs. info, callee)
509
503
maybe_callsite (cs:: Callsite , @nospecialize (tt:: Type )) = maybe_callsite (cs. info, tt)
510
- maybe_callsite (info:: CallInfo , callee:: MethodInstance ) = maybe_callsite (get_mi (info), callee)
504
+ maybe_callsite (info:: CallInfo , callee:: MethodInstance ) = maybe_callsite (get_ci (info), callee)
511
505
# Special CallInfo cases:
512
506
function maybe_callsite (info:: MultiCallInfo , callee:: MethodInstance )
513
507
for csi in info. callinfos
@@ -527,7 +521,7 @@ function maybe_callsite(info::RTCallInfo, @nospecialize(tt::Type))
527
521
end
528
522
return true
529
523
end
530
- function maybe_callsite (info:: MICallInfo , @nospecialize (tt:: Type ))
524
+ function maybe_callsite (info:: EdgeCallInfo , @nospecialize (tt:: Type ))
531
525
return tt <: info.mi.specTypes
532
526
end
533
527
0 commit comments