Skip to content

Internal compiler error: UndefRefError during compaction #51144

Closed
@maleadt

Description

@maleadt

MWE, reduced from package using Automa.jl (regex code generator):

function f(x, y)
    if if x
        if if if if if if if if if if if if if if if if if if if @goto bar
        end end end end end end end end end end end end end end end end end end end
    end end
    @label foo
    if y end
    @label bar
    if (y || 0) && @goto foo
    end
end

Base.code_ircode(f, (Bool, Bool))
$ manyjulias --asserts master wip.jl                  
[ Info: Translated requested revision master to commit 631b5c39b72d91bec33262e14ce96f74de9aa7b6
ERROR: LoadError: UndefRefError: access to undefined reference
Stacktrace:
  [1] getindex
    @ Core.Compiler ./essentials.jl:13 [inlined]
  [2] getindex
    @ Core.Compiler ./compiler/ssair/ir.jl:244 [inlined]
  [3] process_node!(compact::Core.Compiler.IncrementalCompact, result_idx::Int64, inst::Core.Compiler.Instruction, idx::Int64, processed_idx::Int64, active_bb::Int64, do_rename_ssa::Bool)
    @ Core.Compiler ./compiler/ssair/ir.jl:1361
  [4] process_newnode!(compact::Core.Compiler.IncrementalCompact, new_idx::Int64, new_node_entry::Core.Compiler.Instruction, new_node_info::Core.Compiler.NewNodeInfo, idx::Int64, active_bb::Int64, do_rename_ssa::Bool)
    @ Core.Compiler ./compiler/ssair/ir.jl:1543
  [5] iterate_compact(compact::Core.Compiler.IncrementalCompact)
    @ Core.Compiler ./compiler/ssair/ir.jl:1654
  [6] iterate
    @ Core.Compiler ./compiler/ssair/ir.jl:1597 [inlined]
  [7] compact!(code::Core.Compiler.IRCode, allow_cfg_transforms::Bool)
    @ Core.Compiler ./compiler/ssair/ir.jl:1862
  [8] compact!
    @ Core.Compiler ./compiler/ssair/ir.jl:1860 [inlined]
  [9] run_passes(ci::Core.CodeInfo, sv::Core.Compiler.OptimizationState{Core.Compiler.NativeInterpreter}, caller::Core.Compiler.InferenceResult, optimize_until::Nothing)
    @ Core.Compiler ./compiler/optimize.jl:494
 [10] typeinf_ircode(interp::Core.Compiler.NativeInterpreter, method::Method, atype::Any, sparams::Core.SimpleVector, optimize_until::Nothing)
    @ Core.Compiler ./compiler/typeinfer.jl:922
 [11] code_ircode_by_type(tt::Type; world::UInt64, interp::Core.Compiler.NativeInterpreter, optimize_until::Nothing)
    @ Base ./reflection.jl:1511
 [12] code_ircode_by_type
    @ Base ./reflection.jl:1497 [inlined]
 [13] code_ircode(f::Any, types::Any; kwargs::@Kwargs{})
    @ Base ./reflection.jl:1488
 [14] code_ircode(f::Any, types::Any)
    @ Base ./reflection.jl:1483
 [15] top-level scope
    @ ~/Julia/tools/creduce/main.jl:13

Bisected to #50943

Occurs on PkgEval, https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2023-08/31/BioStockholm.primary.log

Metadata

Metadata

Assignees

Labels

compiler:optimizerOptimization passes (mostly in base/compiler/ssair/)regressionRegression in behavior compared to a previous version

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions