Skip to content

Commit b7171d4

Browse files
committed
update EA: keep arrayinfo::ArrayInfo in EscapeState
1 parent 65c1dde commit b7171d4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ end
449449

450450
const AliasSet = IntDisjointSet{Int}
451451

452+
const ArrayInfo = IdDict{Int,Vector{Int}}
453+
452454
"""
453455
estate::EscapeState
454456
@@ -459,12 +461,13 @@ struct EscapeState
459461
escapes::Vector{EscapeInfo}
460462
aliasset::AliasSet
461463
nargs::Int
464+
arrayinfo::Union{Nothing,ArrayInfo} # TODO make this aware of aliasing of nested arrays
462465
end
463-
function EscapeState(nargs::Int, nstmts::Int)
466+
function EscapeState(nargs::Int, nstmts::Int, arrayinfo::Union{Nothing,ArrayInfo})
464467
escapes = EscapeInfo[
465468
1 i nargs ? ArgEscape() :for i in 1:(nargs+nstmts)]
466469
aliaset = AliasSet(nargs+nstmts)
467-
return EscapeState(escapes, aliaset, nargs)
470+
return EscapeState(escapes, aliaset, nargs, arrayinfo)
468471
end
469472
function getindex(estate::EscapeState, @nospecialize(x))
470473
xidx = iridx(x, estate)
@@ -618,13 +621,10 @@ struct LivenessChange <: Change
618621
end
619622
const Changes = Vector{Change}
620623

621-
const ArrayInfo = IdDict{Int,Vector{Int}}
622-
623624
struct AnalysisState
624625
ir::IRCode
625626
estate::EscapeState
626627
changes::Changes
627-
arrayinfo::Union{Nothing,ArrayInfo} # TODO make this aware of aliasing of nested arrays
628628
end
629629

630630
function getinst(ir::IRCode, idx::Int)
@@ -646,10 +646,10 @@ function analyze_escapes(ir::IRCode, nargs::Int)
646646
stmts = ir.stmts
647647
nstmts = length(stmts) + length(ir.new_nodes.stmts)
648648

649-
estate = EscapeState(nargs, nstmts)
650-
changes = Changes() # keeps changes that happen at current statement
651649
tryregions, arrayinfo = compute_frameinfo(ir)
652-
astate = AnalysisState(ir, estate, changes, arrayinfo)
650+
estate = EscapeState(nargs, nstmts, arrayinfo)
651+
changes = Changes() # keeps changes that happen at current statement
652+
astate = AnalysisState(ir, estate, changes)
653653

654654
local debug_itr_counter = 0
655655
while true
@@ -1628,7 +1628,7 @@ end
16281628
function array_nd_index(astate::AnalysisState, @nospecialize(ary), args::Vector{Any}, nidxs::Int = length(args))
16291629
isa(ary, SSAValue) || return nothing
16301630
aryid = ary.id
1631-
arrayinfo = astate.arrayinfo
1631+
arrayinfo = astate.estate.arrayinfo
16321632
isa(arrayinfo, ArrayInfo) || return nothing
16331633
haskey(arrayinfo, aryid) || return nothing
16341634
dims = arrayinfo[aryid]

0 commit comments

Comments
 (0)