Skip to content
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
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
idx += 1
prevloc = codeloc
end
if code[idx] isa Expr && ssavaluetypes[idx] === Union{}
if ssavaluetypes[idx] === Union{} && code[idx] !== nothing && !(code[idx] isa Core.Const)
if !(idx < length(code) && isa(code[idx + 1], ReturnNode) && !isdefined((code[idx + 1]::ReturnNode), :val))
# insert unreachable in the same basic block after the current instruction (splitting it)
insert!(code, idx + 1, ReturnNode())
Expand Down
24 changes: 24 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5161,3 +5161,27 @@ let x = 1, _Any = Any
foo27031() = bar27031((x, 1.0), Val{_Any})
@test foo27031() == "OK"
end

# Issue #53366
#
# FIXME: This test is quite brittle, since it relies on lowering making a particular
# (and unnecessary) decision to embed a `SlotNumber` in statement position.
#
# This should be re-written to have the bad IR directly, then run type inference +
# SSA conversion. It should also avoid running `compact!` afterward, since that can
# mask bugs by cleaning up unused ϕ nodes that should never have existed.
function issue53366(sc::Threads.Condition)
@lock sc begin
try
if Core.Compiler.inferencebarrier(true)
return nothing
end
return nothing
finally
end
end
end

let (ir, rt) = only(Base.code_ircode(issue53366, (Threads.Condition,)))
Core.Compiler.verify_ir(ir)
end