@@ -1738,6 +1738,7 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
17381738 all_phis = Int[]
17391739 unionphis = Pair{Int,Any}[] # sorted
17401740 compact = IncrementalCompact (ir, true )
1741+ made_changes = false
17411742 for ((_, idx), stmt) in compact
17421743 if isa (stmt, PhiNode)
17431744 push! (all_phis, idx)
@@ -1759,7 +1760,7 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
17591760 # nullify safe `typeassert` calls
17601761 ty, isexact = instanceof_tfunc (argextype (stmt. args[3 ], compact), true )
17611762 if isexact && ⊑ (𝕃ₒ, argextype (stmt. args[2 ], compact), ty)
1762- compact[idx] = nothing
1763+ delete_inst_here! ( compact)
17631764 continue
17641765 end
17651766 end
@@ -1801,6 +1802,7 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
18011802 if t === Union{}
18021803 stmt = compact[SSAValue (phi)][:stmt ]:: PhiNode
18031804 kill_phi! (compact, phi_uses, 1 : length (stmt. values), SSAValue (phi), stmt, true )
1805+ made_changes = true
18041806 continue
18051807 elseif t === Any
18061808 continue
@@ -1822,16 +1824,17 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
18221824 end
18231825 compact. result[phi][:type ] = t
18241826 kill_phi! (compact, phi_uses, to_drop, SSAValue (phi), stmt, false )
1827+ made_changes = true
18251828 end
18261829 # Perform simple DCE for unused values
18271830 extra_worklist = Int[]
18281831 for (idx, nused) in Iterators. enumerate (compact. used_ssas)
18291832 idx >= compact. result_idx && break
18301833 nused == 0 || continue
1831- adce_erase! (phi_uses, extra_worklist, compact, idx, false )
1834+ made_changes |= adce_erase! (phi_uses, extra_worklist, compact, idx, false )
18321835 end
18331836 while ! isempty (extra_worklist)
1834- adce_erase! (phi_uses, extra_worklist, compact, pop! (extra_worklist), true )
1837+ made_changes |= adce_erase! (phi_uses, extra_worklist, compact, pop! (extra_worklist), true )
18351838 end
18361839 # Go back and erase any phi cycles
18371840 changed = true
@@ -1852,10 +1855,11 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
18521855 while ! isempty (extra_worklist)
18531856 if adce_erase! (phi_uses, extra_worklist, compact, pop! (extra_worklist), true )
18541857 changed = true
1858+ made_changes = true
18551859 end
18561860 end
18571861 end
1858- return complete (compact)
1862+ return Pair {IRCode, Bool} ( complete (compact), made_changes )
18591863end
18601864
18611865function is_bb_empty (ir:: IRCode , bb:: BasicBlock )
0 commit comments