Skip to content

compact! does not clean-up unused ϕ nodes with ::Union{} type #53640

@topolarity

Description

@topolarity

This accounts for the difference observed in #53512 (comment), since somewhere between 1.9 and 1.10 we stopped wrapping those buggy ϕ's in Core.Compiler.MaybeUndef().

MWE:

julia> include("test/compiler/irutils.jl")
make_ircode (generic function with 1 method)

julia> let code = Any[
                      # block 1
                      #= %1 =# Expr(:call, :opaque),
                      #= %2 =# Core.GotoIfNot(Core.SSAValue(1), 4),
                      # block 2
                      #= %3 =# nothing,
                      # block 3
                      #= %4 =# Core.PhiNode(Int32[2,3], Array{Any}(undef, 2)),
                      #= %5 =# Core.ReturnNode(nothing),
                  ]
                  ir = make_ircode(code)
                  ir.stmts.type[4] = Union{}
                  ir.stmts.flag[4] |= Core.Compiler.IR_FLAG_EFFECT_FREE | Core.Compiler.IR_FLAG_NOTHROW | Core.Compiler.IR_FLAG_CONSISTENT
                  Core.Compiler.compact!(ir)
              end
 1%1 = opaque()::Any                                                                                                                                                 │
 └──      goto #3 if not %1                                                                                                                                             │
 2nothing::Nothing3 ┄      φ (#1 => #undef, #2 => #undef)::Union{}                                                                                                                       │
 └──      return nothing

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:codegenGeneration of LLVM IR and native code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions