@@ -372,10 +372,7 @@ function lift_leaves(compact::IncrementalCompact,
372372 lift_arg! (compact, leaf, cache_key, def, 1 + field, lifted_leaves)
373373 continue
374374 elseif isexpr (def, :new )
375- typ = widenconst (types (compact)[leaf])
376- if isa (typ, UnionAll)
377- typ = unwrap_unionall (typ)
378- end
375+ typ = unwrap_unionall (widenconst (types (compact)[leaf]))
379376 (isa (typ, DataType) && ! isabstracttype (typ)) || return nothing
380377 @assert ! ismutabletype (typ)
381378 if length (def. args) < 1 + field
@@ -786,10 +783,7 @@ function sroa_pass!(ir::IRCode)
786783 push! (preserved, preserved_arg. id)
787784 continue
788785 elseif isexpr (def, :new )
789- typ = widenconst (argextype (SSAValue (defidx), compact))
790- if isa (typ, UnionAll)
791- typ = unwrap_unionall (typ)
792- end
786+ typ = unwrap_unionall (widenconst (argextype (SSAValue (defidx), compact)))
793787 if typ isa DataType && ! ismutabletype (typ)
794788 record_immutable_preserve! (new_preserves, def, compact)
795789 push! (preserved, preserved_arg. id)
@@ -948,10 +942,7 @@ function sroa_mutables!(ir::IRCode, defuses::IdDict{Int, Tuple{SPCSet, SSADefUse
948942 defexpr = ir[SSAValue (idx)][:inst ]
949943 isexpr (defexpr, :new ) || continue
950944 newidx = idx
951- typ = ir. stmts[newidx][:type ]
952- if isa (typ, UnionAll)
953- typ = unwrap_unionall (typ)
954- end
945+ typ = unwrap_unionall (ir. stmts[newidx][:type ])
955946 # Could still end up here if we tried to setfield! on an immutable, which would
956947 # error at runtime, but is not illegal to have in the IR.
957948 ismutabletype (typ) || continue
@@ -1023,6 +1014,13 @@ function sroa_mutables!(ir::IRCode, defuses::IdDict{Int, Tuple{SPCSet, SSADefUse
10231014 end
10241015 has_safe_def (ir, get_domtree (), allblocks, du, newidx, use. idx) || @goto skip
10251016 end
1017+ else # always have some definition at the allocation site
1018+ for i = 1 : length (du. uses)
1019+ use = du. uses[i]
1020+ if use. kind === :isdefined
1021+ ir[SSAValue (use. idx)][:inst ] = true
1022+ end
1023+ end
10261024 end
10271025 end
10281026 # Everything accounted for. Go field by field and perform idf:
0 commit comments