From de297fa0b49ec4a1ae7d90ca6eccc0ff6d771ebd Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:11:21 +0900 Subject: [PATCH] remove special case for the no-op first statement in `fully_eliminated` (#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`. --- test/compiler/irutils.jl | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/test/compiler/irutils.jl b/test/compiler/irutils.jl index 9c79f40f33280..6b66a3e7ce33e 100644 --- a/test/compiler/irutils.jl +++ b/test/compiler/irutils.jl @@ -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)