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

Assertion failure during SROA #52819

Closed
maleadt opened this issue Jan 8, 2024 · 0 comments · Fixed by #52866
Closed

Assertion failure during SROA #52819

maleadt opened this issue Jan 8, 2024 · 0 comments · Fixed by #52866
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) regression Regression in behavior compared to a previous version
Milestone

Comments

@maleadt
Copy link
Member

maleadt commented Jan 8, 2024

As seen on PkgEval: https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2024-01/07/Comonicon.primary.log

Internal error: during type inference of
with_logstate(TestD.var"#1#2", Base.CoreLogging.LogState)
Encountered unexpected error in runtime:
MethodError(f=Base.string, args=(Expr(:call, :in, Expr(:ref, :scope_mapping, :bb), Expr(:tuple, :val, Expr(:call, :SSAValue, 0))),), world=0x00000000000016ae)
jl_method_error_bare at /source/src/gf.c:2216
jl_method_error at /source/src/gf.c:2234
jl_lookup_generic_ at /source/src/gf.c:3079 [inlined]
ijl_apply_generic at /source/src/gf.c:3094
macro expansion at ./error.jl:233 [inlined]
update_scope_mapping! at ./compiler/ssair/passes.jl:1150
sroa_pass! at ./compiler/ssair/passes.jl:1216
run_passes_ipo_safe at ./compiler/optimize.jl:908
run_passes_ipo_safe at ./compiler/optimize.jl:923 [inlined]
optimize at ./compiler/optimize.jl:897

The string MethodError is a red herring; #50536.

MWE:

macro cast(ex)
    return quote
        Core.@__doc__ identity
        $cast()
    end
end
cast() = JLMD()
f() = @cast foo(a) = nothing
Base.code_ircode(Base.CoreLogging.with_logstate, Tuple{typeof(f), Base.CoreLogging.LogState})
ERROR: LoadError: AssertionError: scope_mapping[bb] in (val, SSAValue(0))
Stacktrace:
  [1] update_scope_mapping!(scope_mapping::Vector{Core.SSAValue}, bb::Int64, val::Core.SSAValue)
    @ Core.Compiler ./compiler/ssair/passes.jl:1150
  [2] sroa_pass!(ir::Core.Compiler.IRCode, inlining::Core.Compiler.InliningState{Core.Compiler.NativeInterpreter})
    @ Core.Compiler ./compiler/ssair/passes.jl:1216
  [3] run_passes_ipo_safe(ci::Core.CodeInfo, sv::Core.Compiler.OptimizationState{Core.Compiler.NativeInterpreter}, caller::Core.Compiler.InferenceResult, optimize_until::Nothing)
    @ Core.Compiler ./compiler/optimize.jl:908
  [4] typeinf_ircode(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance, optimize_until::Nothing)
    @ Core.Compiler ./compiler/typeinfer.jl:984
  [5] typeinf_ircode(interp::Core.Compiler.NativeInterpreter, mi::Core.MethodInstance, optimize_until::Nothing)
    @ Core.Compiler ./compiler/typeinfer.jl:969 [inlined]
  [6] code_ircode_by_type(tt::Type; world::UInt64, interp::Core.Compiler.NativeInterpreter, optimize_until::Nothing)
    @ Base ./reflection.jl:1698
  [7] code_ircode_by_type
    @ ./reflection.jl:1685 [inlined]
  [8] code_ircode(f::Any, types::Any; kwargs::@Kwargs{})
    @ Base ./reflection.jl:1676
  [9] code_ircode(f::Any, types::Any)
    @ Base ./reflection.jl:1671
 [10] top-level scope
    @ ~/Julia/tools/creduce/main.jl:9

Bisected to #52608; cc @Keno.

@maleadt maleadt added regression Regression in behavior compared to a previous version compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Jan 8, 2024
@maleadt maleadt added this to the 1.11 milestone Jan 8, 2024
Keno added a commit that referenced this issue Jan 12, 2024
It's possible for this assertion to be violated if there's dead code
in the middle of the function. I think the best thing to do here is
just to relax the assertion to allow this particular case.
Fixes #52819.
Keno added a commit that referenced this issue Jan 12, 2024
It's possible for this assertion to be violated if there's dead code
in the middle of the function. I think the best thing to do here is
just to relax the assertion to allow this particular case.
Fixes #52819.
@Keno Keno closed this as completed in 270ea64 Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant