Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oracle check failure in adce_pass #47080

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions base/compiler/ssair/ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -881,17 +881,20 @@ function getindex(view::TypesView, v::OldSSAValue)
return view.ir.pending_nodes.stmts[id][:type]
end

function kill_current_use(compact::IncrementalCompact, @nospecialize(val))
if isa(val, SSAValue)
@assert compact.used_ssas[val.id] >= 1
compact.used_ssas[val.id] -= 1
elseif isa(val, NewSSAValue)
@assert val.id < 0
@assert compact.new_new_used_ssas[-val.id] >= 1
compact.new_new_used_ssas[-val.id] -= 1
end
end

function kill_current_uses(compact::IncrementalCompact, @nospecialize(stmt))
for ops in userefs(stmt)
val = ops[]
if isa(val, SSAValue)
@assert compact.used_ssas[val.id] >= 1
compact.used_ssas[val.id] -= 1
elseif isa(val, NewSSAValue)
@assert val.id < 0
@assert compact.new_new_used_ssas[-val.id] >= 1
compact.new_new_used_ssas[-val.id] -= 1
end
kill_current_use(compact, ops[])
end
end

Expand Down
5 changes: 4 additions & 1 deletion base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ function adce_pass!(ir::IRCode)
phi = unionphi[1]
t = unionphi[2]
if t === Union{}
compact.result[phi][:inst] = nothing
compact[SSAValue(phi)] = nothing
continue
elseif t === Any
continue
Expand All @@ -1604,6 +1604,9 @@ function adce_pass!(ir::IRCode)
end
compact.result[phi][:type] = t
isempty(to_drop) && continue
for d in to_drop
isassigned(stmt.values, d) && kill_current_use(compact, stmt.values[d])
end
deleteat!(stmt.values, to_drop)
deleteat!(stmt.edges, to_drop)
end
Expand Down