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

remove special case for the no-op first statement in fully_eliminated #51227

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
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
25 changes: 8 additions & 17 deletions test/compiler/irutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,15 @@ fully_eliminated(@nospecialize args...; retval=(@__FILE__), kwargs...) =
fully_eliminated(src::CodeInfo; retval=(@__FILE__)) = fully_eliminated(src.code; retval)
fully_eliminated(ir::IRCode; retval=(@__FILE__)) = fully_eliminated(ir.stmts.stmt; retval)
function fully_eliminated(code::Vector{Any}; retval=(@__FILE__), kwargs...)
if retval !== (@__FILE__)
(length(code) <= 2) || return false
for i = 1:(length(code) - 1)
code[i] === nothing || return false
end
isreturn(code[end]) || return false
val = code[end].val
if val isa QuoteNode
val = val.value
end
return val == retval
else
(length(code) <= 2) || return false
for i = 1:(length(code) - 1)
code[i] === nothing || return false
end
return isreturn(code[end])
length(code) == 1 || return false
retstmt = only(code)
isreturn(retstmt) || return false
retval === (@__FILE__) && return true
retval′ = retstmt.val
if retval′ isa QuoteNode
val = retval′.value
aviatesk marked this conversation as resolved.
Show resolved Hide resolved
end
return val == retval
aviatesk marked this conversation as resolved.
Show resolved Hide resolved
end
macro fully_eliminated(ex0...)
return gen_call_with_extracted_types_and_kwargs(__module__, :fully_eliminated, ex0)
Expand Down