Skip to content

Commit a575e70

Browse files
committed
update EA: rename lattice operations
1 parent b5948d1 commit a575e70

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

base/compiler/ssair/EscapeAnalysis/EAUtils.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ end
289289

290290
import Core: Argument, SSAValue
291291
import .CC: widenconst, singleton_type
292-
import .EA: EscapeInfo, EscapeState, ,
292+
import .EA: EscapeInfo, EscapeState
293293

294294
# in order to run a whole analysis from ground zero (e.g. for benchmarking, etc.)
295295
__clear_caches!() = (__clear_code_cache!(); EA.__clear_escape_cache!())
@@ -349,6 +349,12 @@ Base.show(io::IO, result::EscapeResult) = print_with_info(io, result.ir, result.
349349
@eval Base.iterate(res::EscapeResult, state=1) =
350350
return state > $(fieldcount(EscapeResult)) ? nothing : (getfield(res, state), state+1)
351351

352+
@static if isdefined(EscapeAnalysis, :EscapeCache)
353+
import EscapeAnalysis: EscapeCache
354+
Base.show(io::IO, cached::EscapeCache) =
355+
show(io, EscapeResult(cached.ir, cached.state, nothing))
356+
end
357+
352358
# adapted from https://github.com/JuliaDebug/LoweredCodeUtils.jl/blob/4612349432447e868cf9285f647108f43bd0a11c/src/codeedges.jl#L881-L897
353359
function print_with_info(io::IO,
354360
ir::IRCode, state::EscapeState, linfo::Union{Nothing,MethodInstance})

base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import ._TOP_MOD: # Base definitions
2929
import Core.Compiler: # Core.Compiler specific definitions
3030
isbitstype, isexpr, is_meta_expr_head, println,
3131
IRCode, IR_FLAG_EFFECT_FREE, widenconst, argextype, singleton_type, fieldcount_noerror,
32-
try_compute_field, try_compute_fieldidx, hasintersect, as , intrinsic_nothrow,
32+
try_compute_field, try_compute_fieldidx, hasintersect, , intrinsic_nothrow,
3333
array_builtin_common_typecheck, arrayset_typecheck, setfield!_nothrow, alloc_array_ndims
3434

3535
if _TOP_MOD !== Core.Compiler
@@ -184,14 +184,14 @@ AllEscape() = EscapeInfo(true, true, TOP_THROWN_ESCAPE, TOP_ALIAS_INFO, TOP_LIVE
184184

185185
const ⊥, ⊤ = NotAnalyzed(), AllEscape()
186186

187-
# Convenience names for some ⊑ queries
187+
# Convenience names for some ⊑ queries
188188
has_no_escape(x::EscapeInfo) = !x.ReturnEscape && isempty(x.ThrownEscape) && 0 x.Liveness
189189
has_arg_escape(x::EscapeInfo) = 0 in x.Liveness
190190
has_return_escape(x::EscapeInfo) = x.ReturnEscape
191191
has_return_escape(x::EscapeInfo, pc::Int) = x.ReturnEscape && pc in x.Liveness
192192
has_thrown_escape(x::EscapeInfo) = !isempty(x.ThrownEscape)
193193
has_thrown_escape(x::EscapeInfo, pc::Int) = pc in x.ThrownEscape
194-
has_all_escape(x::EscapeInfo) = x
194+
has_all_escape(x::EscapeInfo) = x
195195

196196
# utility lattice constructors
197197
ignore_argescape(x::EscapeInfo) = EscapeInfo(x; Liveness=delete!(copy(x.Liveness), 0))
@@ -241,11 +241,11 @@ x::EscapeInfo == y::EscapeInfo = begin
241241
end
242242

243243
"""
244-
x::EscapeInfo ⊑ y::EscapeInfo -> Bool
244+
x::EscapeInfo ⊑ y::EscapeInfo -> Bool
245245
246246
The non-strict partial order over `EscapeInfo`.
247247
"""
248-
x::EscapeInfo y::EscapeInfo = begin
248+
x::EscapeInfo y::EscapeInfo = begin
249249
# fast pass: better to avoid top comparison
250250
if y ===
251251
return true
@@ -324,27 +324,27 @@ x::EscapeInfo ⊑ y::EscapeInfo = begin
324324
end
325325

326326
"""
327-
x::EscapeInfo ⊏ y::EscapeInfo -> Bool
327+
x::EscapeInfo ⊏ y::EscapeInfo -> Bool
328328
329329
The strict partial order over `EscapeInfo`.
330-
This is defined as the irreflexive kernel of `⊏`.
330+
This is defined as the irreflexive kernel of `⊏`.
331331
"""
332-
x::EscapeInfo y::EscapeInfo = x y && !(y x)
332+
x::EscapeInfo y::EscapeInfo = x y && !(y x)
333333

334334
"""
335-
x::EscapeInfo ⋤ y::EscapeInfo -> Bool
335+
x::EscapeInfo ⋤ y::EscapeInfo -> Bool
336336
337-
This order could be used as a slightly more efficient version of the strict order `⊏`,
338-
where we can safely assume `x ⊑ y` holds.
337+
This order could be used as a slightly more efficient version of the strict order `⊏`,
338+
where we can safely assume `x ⊑ y` holds.
339339
"""
340-
x::EscapeInfo y::EscapeInfo = !(y x)
340+
x::EscapeInfo y::EscapeInfo = !(y x)
341341

342342
"""
343-
x::EscapeInfo ⊔ y::EscapeInfo -> EscapeInfo
343+
x::EscapeInfo ⊔ y::EscapeInfo -> EscapeInfo
344344
345345
Computes the join of `x` and `y` in the partial order defined by `EscapeInfo`.
346346
"""
347-
x::EscapeInfo y::EscapeInfo = begin
347+
x::EscapeInfo y::EscapeInfo = begin
348348
# fast pass: better to avoid top join
349349
if x ===|| y ===
350350
return
@@ -756,7 +756,7 @@ function propagate_changes!(estate::EscapeState, changes::Changes)
756756
end
757757

758758
@inline propagate_escape_change!(estate::EscapeState, change::EscapeChange) =
759-
propagate_escape_change!(, estate, change)
759+
propagate_escape_change!(, estate, change)
760760

761761
# allows this to work as lattice join as well as lattice meet
762762
@inline function propagate_escape_change!(@specialize(op),
@@ -811,7 +811,7 @@ end
811811
union!(estate.aliasset, xroot, yroot)
812812
xinfo = estate.escapes[xidx]
813813
yinfo = estate.escapes[yidx]
814-
xyinfo = xinfo yinfo
814+
xyinfo = xinfo yinfo
815815
estate.escapes[xidx] = xyinfo
816816
estate.escapes[yidx] = xyinfo
817817
return true
@@ -1670,9 +1670,9 @@ end
16701670

16711671
function arraysize_typecheck(@nospecialize(ary), @nospecialize(dim), ir::IRCode)
16721672
aryt = argextype(ary, ir)
1673-
aryt Array || return false
1673+
aryt Array || return false
16741674
dimt = argextype(dim, ir)
1675-
dimt Int || return false
1675+
dimt Int || return false
16761676
return true
16771677
end
16781678

@@ -1697,11 +1697,11 @@ function escape_array_resize!(boundserror::Bool, ninds::Int,
16971697
length(args) 6+ninds || return add_fallback_changes!(astate, pc, args)
16981698
ary = args[6]
16991699
aryt = argextype(ary, astate.ir)
1700-
aryt Array || return add_fallback_changes!(astate, pc, args)
1700+
aryt Array || return add_fallback_changes!(astate, pc, args)
17011701
for i in 1:ninds
17021702
ind = args[i+6]
17031703
indt = argextype(ind, astate.ir)
1704-
indt Integer || return add_fallback_changes!(astate, pc, args)
1704+
indt Integer || return add_fallback_changes!(astate, pc, args)
17051705
end
17061706
if boundserror
17071707
# this array resizing can potentially throw `BoundsError`, impose it now
@@ -1729,7 +1729,7 @@ function escape_array_copy!(astate::AnalysisState, pc::Int, args::Vector{Any})
17291729
length(args) 6 || return add_fallback_changes!(astate, pc, args)
17301730
ary = args[6]
17311731
aryt = argextype(ary, astate.ir)
1732-
aryt Array || return add_fallback_changes!(astate, pc, args)
1732+
aryt Array || return add_fallback_changes!(astate, pc, args)
17331733
if isa(ary, SSAValue) || isa(ary, Argument)
17341734
newary = SSAValue(pc)
17351735
aryinfo = astate.estate[ary]
@@ -1756,9 +1756,9 @@ function array_isassigned_nothrow(args::Vector{Any}, src::IRCode)
17561756
# end
17571757
length(args) 7 || return false
17581758
arytype = argextype(args[6], src)
1759-
arytype Array || return false
1759+
arytype Array || return false
17601760
idxtype = argextype(args[7], src)
1761-
idxtype Csize_t || return false
1761+
idxtype Csize_t || return false
17621762
return true
17631763
end
17641764

@@ -1787,7 +1787,7 @@ escape_builtin!(::typeof(arraythaw), astate::AnalysisState, pc::Int, args::Vecto
17871787
is_safe_immutable_array_op(ImmutableArray, astate, args)
17881788
function is_safe_immutable_array_op(@nospecialize(arytype), astate::AnalysisState, args::Vector{Any})
17891789
length(args) == 2 || return false
1790-
argextype(args[2], astate.ir) arytype || return false
1790+
argextype(args[2], astate.ir) arytype || return false
17911791
return true
17921792
end
17931793

0 commit comments

Comments
 (0)