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

add option to verify_ir that allows front_end forms #45786

Merged
merged 1 commit into from
Jun 27, 2022
Merged
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
14 changes: 8 additions & 6 deletions base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if !isdefined(@__MODULE__, Symbol("@verify_error"))
end
end

function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int, use_idx::Int, print::Bool, isforeigncall::Bool, arg_idx::Int)
function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int, use_idx::Int, print::Bool, isforeigncall::Bool, arg_idx::Int, allow_frontend_forms::Bool)
if isa(op, SSAValue)
if op.id > length(ir.stmts)
def_bb = block_for_inst(ir.cfg, ir.new_nodes.info[op.id - length(ir.stmts)].pos)
Expand Down Expand Up @@ -47,8 +47,10 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
# a real call - it's interpreted in global scope by codegen. However,
# we do need to keep this a real use, because it could also be a pointer.
elseif op.head !== :boundscheck
@verify_error "Expr not allowed in value position"
error("")
if !allow_frontend_forms || op.head !== :opaque_closure_method
@verify_error "Expr not allowed in value position"
error("")
end
end
elseif isa(op, Union{OldSSAValue, NewSSAValue})
#@Base.show ir
Expand All @@ -70,7 +72,7 @@ function count_int(val::Int, arr::Vector{Int})
n
end

function verify_ir(ir::IRCode, print::Bool=true)
function verify_ir(ir::IRCode, print::Bool=true, allow_frontend_forms::Bool=false)
# For now require compact IR
# @assert isempty(ir.new_nodes)
# Verify CFG
Expand Down Expand Up @@ -189,7 +191,7 @@ function verify_ir(ir::IRCode, print::Bool=true)
#error("")
end
end
check_op(ir, domtree, val, Int(edge), last(ir.cfg.blocks[stmt.edges[i]].stmts)+1, print, false, i)
check_op(ir, domtree, val, Int(edge), last(ir.cfg.blocks[stmt.edges[i]].stmts)+1, print, false, i, allow_frontend_forms)
end
elseif isa(stmt, PhiCNode)
for i = 1:length(stmt.values)
Expand Down Expand Up @@ -238,7 +240,7 @@ function verify_ir(ir::IRCode, print::Bool=true)
n = 1
for op in userefs(stmt)
op = op[]
check_op(ir, domtree, op, bb, idx, print, isforeigncall, n)
check_op(ir, domtree, op, bb, idx, print, isforeigncall, n, allow_frontend_forms)
n += 1
end
end
Expand Down