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

bad PhiNode renumbering of #undef value #55388

Open
vtjnash opened this issue Aug 6, 2024 · 0 comments
Open

bad PhiNode renumbering of #undef value #55388

vtjnash opened this issue Aug 6, 2024 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)

Comments

@vtjnash
Copy link
Member

vtjnash commented Aug 6, 2024

I accidentally wrote this function, where ct was #undef in state3, but it probably should not have crashed the slot2ssa pass:

julia> function donext(nextstate)
    nextstate === 0x3 && @goto state3
    while @noinline rand(Bool) # any sort of scope block, such as let or while
        ct = @noinline rand(Bool) ? [] : nothing # something type-unstable
        if @noinline rand(Bool)
            return
            @label state3
        end
        Base.donotdelete(ct) # some use of ct
    end
    nothing
end

julia> code_typed(donext, (UInt8,))
ERROR: BoundsError: attempt to access 37-element Vector{Core.SSAValue} at index [-2]
Stacktrace:
  [1] throw_boundserror(A::Vector{Core.SSAValue}, I::Tuple{Int64})
    @ Core.Compiler ./essentials.jl:14
  [2] getindex
    @ ./essentials.jl:904 [inlined]
  [3] renumber_ssa(stmt::Core.SSAValue, ssanums::Vector{Core.SSAValue}, new_ssa::Bool)
    @ Core.Compiler ./compiler/ssair/slot2ssa.jl:55
  [4] #482
    @ ./compiler/ssair/slot2ssa.jl:62 [inlined]
  [5] ssamap(f::Core.Compiler.var"#482#483"{Vector{Core.SSAValue}, Bool}, stmt::Any)
    @ Core.Compiler ./compiler/utilities.jl:392
  [6] renumber_ssa!
    @ ./compiler/ssair/slot2ssa.jl:62 [inlined]
  [7] renumber_ssa!
    @ ./compiler/ssair/slot2ssa.jl:61 [inlined]
  [8] construct_ssa!(ci::Core.CodeInfo, ir::Core.Compiler.IRCode, sv::Core.Compiler.OptimizationState{…}, domtree::Core.Compiler.GenericDomTree{…}, defuses::Vector{…}, 𝕃ₒ::Core.Compiler.PartialsLattice{…})
    @ Core.Compiler ./compiler/ssair/slot2ssa.jl:874
  [9] slot2reg
    @ ./compiler/optimize.jl:1259 [inlined]
@vtjnash vtjnash added bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

No branches or pull requests

1 participant