@@ -372,10 +372,7 @@ function lift_leaves(compact::IncrementalCompact,
372
372
lift_arg! (compact, leaf, cache_key, def, 1 + field, lifted_leaves)
373
373
continue
374
374
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]))
379
376
(isa (typ, DataType) && ! isabstracttype (typ)) || return nothing
380
377
@assert ! ismutabletype (typ)
381
378
if length (def. args) < 1 + field
@@ -786,10 +783,7 @@ function sroa_pass!(ir::IRCode)
786
783
push! (preserved, preserved_arg. id)
787
784
continue
788
785
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)))
793
787
if typ isa DataType && ! ismutabletype (typ)
794
788
record_immutable_preserve! (new_preserves, def, compact)
795
789
push! (preserved, preserved_arg. id)
@@ -948,10 +942,7 @@ function sroa_mutables!(ir::IRCode, defuses::IdDict{Int, Tuple{SPCSet, SSADefUse
948
942
defexpr = ir[SSAValue (idx)][:inst ]
949
943
isexpr (defexpr, :new ) || continue
950
944
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 ])
955
946
# Could still end up here if we tried to setfield! on an immutable, which would
956
947
# error at runtime, but is not illegal to have in the IR.
957
948
ismutabletype (typ) || continue
@@ -1023,6 +1014,13 @@ function sroa_mutables!(ir::IRCode, defuses::IdDict{Int, Tuple{SPCSet, SSADefUse
1023
1014
end
1024
1015
has_safe_def (ir, get_domtree (), allblocks, du, newidx, use. idx) || @goto skip
1025
1016
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
1026
1024
end
1027
1025
end
1028
1026
# Everything accounted for. Go field by field and perform idf:
0 commit comments