Skip to content

Commit

Permalink
remove special case for the no-op first statement in `fully_eliminate…
Browse files Browse the repository at this point in the history
…d` (#51227)

It looks like the special case is no longer needed. If this gets broken
by future changes, I would like fix it or mark the test cases as
`broken`.
  • Loading branch information
aviatesk committed Sep 8, 2023
1 parent 39a5316 commit de297fa
Showing 1 changed file with 8 additions and 17 deletions.
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
retval′ = retval′.value
end
return retval′ == retval
end
macro fully_eliminated(ex0...)
return gen_call_with_extracted_types_and_kwargs(__module__, :fully_eliminated, ex0)
Expand Down

0 comments on commit de297fa

Please sign in to comment.