@@ -319,7 +319,7 @@ has_any_genscope(sc::PartialStruct) = false # TODO
319319
320320function _make_argument_lattice_elem (which:: Argument , @nospecialize (argt), add_variable!, add_equation!, add_scope!)
321321 if isa (argt, Const)
322- @assert ! isa (argt. val, Scope) # Shouldn't have been forwarded
322+ # @assert !isa(argt.val, Scope) # Shouldn't have been forwarded
323323 return argt
324324 elseif isa (argt, Type) && argt <: Intrinsics.AbstractScope
325325 return PartialScope (add_scope! (which))
@@ -362,7 +362,7 @@ function make_argument_lattice_elem(which::Argument, @nospecialize(argt), add_va
362362end
363363
364364function resolve_genscopes (names)
365- new_names = OrderedDict {LevelKey , NameLevel} ()
365+ new_names = OrderedDict {Any , NameLevel} ()
366366 for (key, val) in collect (names)
367367 if val. children != = nothing
368368 @reset val. children = resolve_genscopes (val. children)
@@ -423,7 +423,7 @@ Perform the structural analysis on optimized code of `mi` and return `structure:
423423 end
424424end
425425
426- function refresh_identities (names:: OrderedDict{LevelKey, NameLevel} )
426+ function refresh_identities (names:: OrderedDict{LevelKey, NameLevel} ) where {LevelKey, NameLevel}
427427 new_names = OrderedDict {LevelKey, NameLevel} ()
428428 for (key, val) in names
429429 if isa (key, Gen)
502502 eq_kind = VarEqKind[]
503503 warnings = UnsupportedIRException[]
504504
505- names = OrderedDict {LevelKey , NameLevel} ()
505+ names = OrderedDict {Any , NameLevel} ()
506506
507507 nsysmscopes = 0
508508 ncallees = 0
@@ -1191,7 +1191,7 @@ function process_ipo_return!(ultimate_rt::PartialStruct, args...)
11911191 return PartialStruct (ultimate_rt. typ, fields), nimplicitoutpairs
11921192end
11931193
1194- function get_variable_name (names:: OrderedDict{LevelKey, NameLevel} , var_to_diff, var_idx)
1194+ function get_variable_name (names:: OrderedDict , var_to_diff, var_idx)
11951195 var_names = build_var_names (names, var_to_diff)
11961196 return var_names[var_idx]
11971197end
@@ -1221,7 +1221,7 @@ function get_inline_backtrace(ir::IRCode, v::SSAValue)
12211221 return frames
12221222end
12231223
1224- function walk_dict (names:: OrderedDict{LevelKey, NameLevel} , stack:: Vector{<: LevelKey} )
1224+ function walk_dict (names:: OrderedDict{LevelKey, NameLevel} , stack:: Vector ) where { LevelKey, NameLevel}
12251225 for i = length (stack): - 1 : 2
12261226 s = stack[i]
12271227 if ! haskey (names, s)
@@ -1235,11 +1235,11 @@ end
12351235is_valid_partial_scope (_) = false
12361236is_valid_partial_scope (ps:: PartialScope ) = true
12371237function is_valid_partial_scope (ps:: PartialStruct )
1238- if ps. typ === Scope
1238+ if ps. typ <: Scope
12391239 isa (ps. fields[2 ], Const) || return false
12401240 isa (ps. fields[2 ]. val, Symbol) || return false
12411241 return is_valid_partial_scope (ps. fields[1 ])
1242- elseif ps. typ === GenScope
1242+ elseif ps. typ <: GenScope
12431243 isa (ps. fields[1 ], Const) || return false
12441244 return is_valid_partial_scope (ps. fields[2 ])
12451245 else
@@ -1248,11 +1248,11 @@ function is_valid_partial_scope(ps::PartialStruct)
12481248end
12491249
12501250function sym_stack (ps:: PartialStruct )
1251- if ps. typ === Scope
1251+ if ps. typ <: Scope
12521252 sym = (ps. fields[2 ]:: Const ). val:: Symbol
12531253 return pushfirst! (sym_stack (ps. fields[1 ]), sym)
12541254 else
1255- @assert ps. typ === GenScope
1255+ @assert ps. typ <: GenScope
12561256 stack = sym_stack (ps. fields[2 ])
12571257 scope_identity = ((ps. fields[1 ]:: Const ). val):: Intrinsics.ScopeIdentity
12581258 stack[1 ] = Gen (scope_identity, stack[1 ])
@@ -1261,7 +1261,7 @@ function sym_stack(ps::PartialStruct)
12611261end
12621262
12631263sym_stack (ps:: PartialScope ) = LevelKey[ps]
1264- function record_scope! (ir:: IRCode , names:: OrderedDict{LevelKey, NameLevel} , scope:: Union{Scope, GenScope, PartialStruct, PartialScope} ,
1264+ function record_scope! (ir:: IRCode , names:: OrderedDict , scope:: Union{Scope, GenScope, PartialStruct, PartialScope} ,
12651265 varssa:: Vector , idx:: Int , lens)
12661266
12671267 stack = sym_stack (scope)
@@ -1282,11 +1282,15 @@ function record_scope!(ir::IRCode, names::OrderedDict{LevelKey, NameLevel}, scop
12821282end
12831283
12841284function merge_scopes! (names:: OrderedDict{LevelKey, NameLevel} , key:: LevelKey , val:: NameLevel ,
1285- mapping:: CalleeMapping , obsoffset:: Int , epsoffset:: Int )
1285+ mapping:: CalleeMapping , obsoffset:: Int , epsoffset:: Int ) where {LevelKey, NameLevel}
12861286
12871287 haskey (names, key) || (names[key] = NameLevel ())
12881288 existing = names[key]
1289- for (offset, lens) in ((x-> (only (findnz (mapping. var_coeffs[x]. row)[1 ])), @o _. var),
1289+ function remap_var (x)
1290+ r = only (findnz (mapping. var_coeffs[x]. row)[1 ]) - 1
1291+ return r
1292+ end
1293+ for (offset, lens) in ((remap_var, @o _. var),
12901294 (x-> (x+ obsoffset), @o _. obs),
12911295 (x-> mapping. eqs[x], @o _. eq), (x-> (x+ epsoffset), @o _. eps))
12921296 if lens (val) != = nothing
@@ -1312,7 +1316,7 @@ function merge_scopes!(names::OrderedDict{LevelKey, NameLevel}, key::LevelKey, v
13121316end
13131317
13141318function merge_scopes! (names:: OrderedDict{LevelKey, NameLevel} , key:: Union{Scope, PartialStruct} , val:: NameLevel ,
1315- mapping:: CalleeMapping , obsoffset:: Int , epsoffset:: Int )
1319+ mapping:: CalleeMapping , obsoffset:: Int , epsoffset:: Int ) where {LevelKey, NameLevel}
13161320
13171321 stack = sym_stack (key)
13181322 if isempty (stack)
0 commit comments