@@ -17,7 +17,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
17
17
arginfo:: ArgInfo , si:: StmtInfo , @nospecialize (atype),
18
18
sv:: AbsIntState , max_methods:: Int )
19
19
𝕃ₚ, 𝕃ᵢ = ipo_lattice (interp), typeinf_lattice (interp)
20
- ⊑ ₚ = ⊑ (𝕃ₚ)
20
+ ⊑ ₚ, ⊔ ₚ, ⊔ ᵢ = partialorder (𝕃ₚ), join (𝕃ₚ), join (𝕃ᵢ )
21
21
if ! should_infer_this_call (interp, sv)
22
22
add_remark! (interp, sv, " Skipped call in throw block" )
23
23
# At this point we are guaranteed to end up throwing on this path,
@@ -37,7 +37,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
37
37
(; valid_worlds, applicable, info) = matches
38
38
update_valid_age! (sv, valid_worlds)
39
39
napplicable = length (applicable)
40
- rettype = excttype = Bottom
40
+ rettype = exctype = Bottom
41
41
edges = MethodInstance[]
42
42
conditionals = nothing # keeps refinement information of call argument types when the return type is boolean
43
43
seen = 0 # number of signatures actually inferred
@@ -96,8 +96,8 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
96
96
const_results[i] = const_result
97
97
end
98
98
edge === nothing || push! (edges, edge)
99
- this_rt = tmerge ( this_rt, rt)
100
- this_exct = tmerge ( this_exct, exct)
99
+ this_rt = this_rt ⊔ ₚ rt
100
+ this_exct = this_exct ⊔ ₚ exct
101
101
if bail_out_call (interp, this_rt, sv)
102
102
break
103
103
end
@@ -156,17 +156,17 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
156
156
end
157
157
@assert ! (this_conditional isa Conditional || this_rt isa MustAlias) " invalid lattice element returned from inter-procedural context"
158
158
seen += 1
159
- rettype = tmerge (𝕃ₚ, rettype, this_rt)
160
- excttype = tmerge (𝕃ₚ, excttype, this_exct)
159
+ rettype = rettype ⊔ ₚ this_rt
160
+ exctype = exctype ⊔ ₚ this_exct
161
161
if has_conditional (𝕃ₚ, sv) && this_conditional != = Bottom && is_lattice_bool (𝕃ₚ, rettype) && fargs != = nothing
162
162
if conditionals === nothing
163
163
conditionals = Any[Bottom for _ in 1 : length (argtypes)],
164
164
Any[Bottom for _ in 1 : length (argtypes)]
165
165
end
166
166
for i = 1 : length (argtypes)
167
167
cnd = conditional_argtype (𝕃ᵢ, this_conditional, sig, argtypes, i)
168
- conditionals[1 ][i] = tmerge (𝕃ᵢ, conditionals[1 ][i], cnd. thentype)
169
- conditionals[2 ][i] = tmerge (𝕃ᵢ, conditionals[2 ][i], cnd. elsetype)
168
+ conditionals[1 ][i] = conditionals[1 ][i] ⊔ ᵢ cnd. thentype
169
+ conditionals[2 ][i] = conditionals[2 ][i] ⊔ ᵢ cnd. elsetype
170
170
end
171
171
end
172
172
if bail_out_call (interp, InferenceLoopState (sig, rettype, all_effects), sv)
@@ -182,14 +182,14 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
182
182
183
183
if seen ≠ napplicable
184
184
# there is unanalyzed candidate, widen type and effects to the top
185
- rettype = excttype = Any
185
+ rettype = exctype = Any
186
186
all_effects = Effects ()
187
187
else
188
188
if (matches isa MethodMatches ? (! matches. fullmatch || any_ambig (matches)) :
189
189
(! all (matches. fullmatches) || any_ambig (matches)))
190
190
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
191
191
all_effects = Effects (all_effects; nothrow= false )
192
- excttype = tmerge (𝕃ₚ, excttype, MethodError)
192
+ exctype = exctype ⊔ ₚ MethodError
193
193
end
194
194
if sv isa InferenceState && fargs != = nothing
195
195
slotrefinements = collect_slot_refinements (𝕃ᵢ, applicable, argtypes, fargs, sv)
@@ -240,7 +240,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
240
240
end
241
241
end
242
242
243
- return CallMeta (rettype, excttype , all_effects, info, slotrefinements)
243
+ return CallMeta (rettype, exctype , all_effects, info, slotrefinements)
244
244
end
245
245
246
246
struct FailedMethodMatch
@@ -367,7 +367,7 @@ function from_interprocedural!(interp::AbstractInterpreter, @nospecialize(rt), s
367
367
arginfo:: ArgInfo , @nospecialize (maybecondinfo))
368
368
rt = collect_limitations! (rt, sv)
369
369
if isa (rt, InterMustAlias)
370
- rt = from_intermustalias (rt, arginfo, sv)
370
+ rt = from_intermustalias (typeinf_lattice (interp), rt, arginfo, sv)
371
371
elseif is_lattice_bool (ipo_lattice (interp), rt)
372
372
if maybecondinfo === nothing
373
373
rt = widenconditional (rt)
@@ -387,12 +387,13 @@ function collect_limitations!(@nospecialize(typ), sv::InferenceState)
387
387
return typ
388
388
end
389
389
390
- function from_intermustalias (rt:: InterMustAlias , arginfo:: ArgInfo , sv:: AbsIntState )
390
+ function from_intermustalias (𝕃ᵢ :: AbstractLattice , rt:: InterMustAlias , arginfo:: ArgInfo , sv:: AbsIntState )
391
391
fargs = arginfo. fargs
392
392
if fargs != = nothing && 1 ≤ rt. slot ≤ length (fargs)
393
393
arg = ssa_def_slot (fargs[rt. slot], sv)
394
394
if isa (arg, SlotNumber)
395
395
argtyp = widenslotwrapper (arginfo. argtypes[rt. slot])
396
+ ⊑ = partialorder (𝕃ᵢ)
396
397
if rt. vartyp ⊑ argtyp
397
398
return MustAlias (arg, rt. vartyp, rt. fldidx, rt. fldtyp)
398
399
else
@@ -412,6 +413,7 @@ function from_interconditional(𝕃ᵢ::AbstractLattice, @nospecialize(rt), sv::
412
413
alias = nothing
413
414
thentype = elsetype = Any
414
415
condval = maybe_extract_const_bool (rt)
416
+ ⊑ , ⋤ , ⊓ = partialorder (𝕃ᵢ), strictneqpartialorder (𝕃ᵢ), meet (𝕃ᵢ)
415
417
for i in 1 : length (fargs)
416
418
# find the first argument which supports refinement,
417
419
# and intersect all equivalent arguments with it
@@ -447,24 +449,24 @@ function from_interconditional(𝕃ᵢ::AbstractLattice, @nospecialize(rt), sv::
447
449
end
448
450
if condval === false
449
451
thentype = Bottom
450
- elseif ⊑ (𝕃ᵢ, new_thentype, thentype)
452
+ elseif new_thentype ⊑ thentype
451
453
thentype = new_thentype
452
454
else
453
- thentype = tmeet (𝕃ᵢ, thentype, widenconst (new_thentype) )
455
+ thentype = thentype ⊓ widenconst (new_thentype)
454
456
end
455
457
if condval === true
456
458
elsetype = Bottom
457
- elseif ⊑ (𝕃ᵢ, new_elsetype, elsetype)
459
+ elseif new_elsetype ⊑ elsetype
458
460
elsetype = new_elsetype
459
461
else
460
- elsetype = tmeet (𝕃ᵢ, elsetype, widenconst (new_elsetype) )
462
+ elsetype = elsetype ⊓ widenconst (new_elsetype)
461
463
end
462
- if (slot > 0 || condval != = false ) && ⋤ (𝕃ᵢ, thentype, old)
464
+ if (slot > 0 || condval != = false ) && thentype ⋤ old
463
465
slot = id
464
466
if ! (arg isa SlotNumber) && argtyp isa MustAlias
465
467
alias = argtyp
466
468
end
467
- elseif (slot > 0 || condval != = true ) && ⋤ (𝕃ᵢ, elsetype, old)
469
+ elseif (slot > 0 || condval != = true ) && elsetype ⋤ old
468
470
slot = id
469
471
if ! (arg isa SlotNumber) && argtyp isa MustAlias
470
472
alias = argtyp
@@ -1368,7 +1370,6 @@ function matching_cache_argtypes(𝕃::AbstractLattice, mi::MethodInstance,
1368
1370
given_argtypes = Vector {Any} (undef, length (argtypes))
1369
1371
def = mi. def:: Method
1370
1372
nargs = Int (def. nargs)
1371
- local condargs = nothing
1372
1373
for i in 1 : length (argtypes)
1373
1374
argtype = argtypes[i]
1374
1375
# forward `Conditional` if it conveys a constraint on any other argument
@@ -1385,10 +1386,6 @@ function matching_cache_argtypes(𝕃::AbstractLattice, mi::MethodInstance,
1385
1386
# TODO bail out here immediately rather than just propagating Bottom ?
1386
1387
given_argtypes[i] = Bottom
1387
1388
else
1388
- if condargs === nothing
1389
- condargs = Tuple{Int,Int}[]
1390
- end
1391
- push! (condargs, (slotid, i))
1392
1389
given_argtypes[i] = Conditional (slotid, thentype, elsetype)
1393
1390
end
1394
1391
continue
0 commit comments