JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.48k stars 5.46k forks source link

frequent verify_ir failures (invalid SSA domination) when building #46943

Closed vtjnash closed 1 year ago

vtjnash commented 1 year ago

Enable output with this diff to see the errors with make debug

diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl
index acd61be502..e2fc129752 100644
--- a/contrib/generate_precompile.jl
+++ b/contrib/generate_precompile.jl
@@ -242,7 +242,7 @@ const HELP_PROMPT = "help?> "

 function generate_precompile_statements()
     start_time = time_ns()
-    debug_output = devnull # or stdout
+    debug_output = stdout
     sysimg = Base.unsafe_string(Base.JLOptions().image_file)

     # Extract the precompile statements from the precompile file

(note that basic block 11 is unreachable, only 1, 12, 13, and 14)

Basic Block 1 does not dominate block 11 (tried to use value 4)                                                                                                                                    
401 1 ── %1  = Core.sext_int(Core.Int64, _2)::Int64         │╻╷   Int64                                                                                                                            
    │    %2  = Core.sext_int(Core.Int64, _3)::Int64         ││╻    toInt64                                                                                                                         
    │    %3  = Core.sext_int(Core.Int64, _4)::Int64         ││╻    toInt64                                                                                                                         
    │    %4  = Core.sext_int(Core.Int64, _5)::Int64         ││╻    toInt64                                                                                                                         
    │    %5  = Core.sext_int(Core.Int64, _6)::Int64         ││╻    toInt64                                                                                                                         
    │    %6  = Core.sext_int(Core.Int64, _7)::Int64         ││╻    toInt64                                                                                                                         
    │    %7  = invoke Dates.validargs(Dates.DateTime::Type{Dates.DateTime}, %1::Int64, %2::Int64, %3::Int64, %4::Int64, %5::Int64, %6::Int64, _8::Int64, _9::Dates.AMPM)::Union{Nothing, ArgumentEr
ror}                                                                                                                                                                                               
    │    %8  = (%7 === Dates.nothing)::Bool                 ││                                                                                                                                     
    └───       goto #13 if not %8                           ││                                                                                                                                     
    2 ──       goto #12                                     ││╻    adjusthour                                                                                                                      
    3 ── %11 = (_9 === Dates.PM)::Bool                      │││╻    ==                                                                                                                             
    └───       goto #7 if not %11                           │││                                                                                                                                    
    4 ── %13 = Base.slt_int(%4, 12)::Bool                   ││││╻    <                                                                                                                             
    └───       goto #6 if not %13                           │││                                                                                                                                    
    5 ── %15 = Base.add_int(%4, 12)::Int64                  ││││╻    +                                                                                                                             
    └───       goto #12                                     │││                                                                                                                                    
    6 ──       nothing::Nothing                             │                                                                                                                                      
    7 ┄─ %18 = (_9 === Dates.AM)::Bool                      │││╻    ==                                                                                                                             
    └───       goto #11 if not %18                          │││                                                                                                                                    
    8 ── %20 = (%4 === 12)::Bool                            ││││╻    ==                                                                                                                            
    └───       goto #10 if not %20                          │││                                                                                                                                    
    9 ──       goto #12                                     │││                                                                                                                                    
    10 ─       nothing::Nothing                             │                                                                                                                                      
    11 ┄       goto #12                                     │││                                                                                                                                    
    12 ┄ %25 = φ (#2 => %4, #5 => %15, #9 => 0, #11 => %4)::Int64                                                                                                                                  
    │    %26 = Base.mul_int(60, %5)::Int64                  ││╻╷   *                                                                                                                               
    │    %27 = Base.mul_int(3600, %25)::Int64               │││╻    *                                                                                                                              
    │    %28 = invoke Dates.totaldays(%1::Int64, %2::Int64, %3::Int64)::Int64                                                                                                                      
    │    %29 = Base.mul_int(86400, %28)::Int64              │││╻    *                                                                                                                              
    │    %30 = Base.add_int(%6, %26)::Int64                 │││╻    +                                                                                                                              
    │    %31 = Base.add_int(%30, %27)::Int64                ││││                                                                                                                                   
    │    %32 = Base.add_int(%31, %29)::Int64                ││││╻    +                                                                                                                             
    │    %33 = Base.mul_int(1000, %32)::Int64               │││╻    *                                                                                                                              
    │    %34 = Base.add_int(_8, %33)::Int64                 ││╻    +                                                                                                                               
    │    %35 = %new(Dates.Millisecond, %34)::Dates.Millisecond╻╷   UTM                                                                                                                             
    │    %36 = %new(Dates.UTInstant{Dates.Millisecond}, %35)::Dates.UTInstant{Dates.Millisecond}                                                                                                   
    │    %37 = %new(Dates.DateTime, %36)::Dates.DateTime    ││╻    DateTime                                                                                                                        
    └───       goto #14                                     ││                                                                                                                                     
    13 ─ %39 = π (%7, ArgumentError)                        ││                                                                                                                                     
    │          Dates.throw(%39)::Union{}                    ││                                                                                                                                     
    └───       unreachable                                  ││                                                                                                                                     
    14 ─       return %37                                   │                                                                                                                                      

Internal error: encountered unexpected error in runtime:                                                                                                                                           
ErrorException("")                                                                                                                                                                                 
error at ./error.jl:35                                                                                                                                                                             
check_op at ./compiler/ssair/verify.jl:44                                                                                                                                                          
verify_ir at ./compiler/ssair/verify.jl:204                                                                                                                                                        
verify_ir at ./compiler/ssair/verify.jl:89 [inlined]                                                                                                                                               
run_passes at ./compiler/optimize.jl:557                                                                                                                                                           
run_passes at ./compiler/optimize.jl:543 [inlined]                                                                                                                                                 
optimize at ./compiler/optimize.jl:492 [inlined]                                                                                                                                                   
_typeinf at ./compiler/typeinfer.jl:259                                                                                                                                                            
typeinf at ./compiler/typeinfer.jl:215                                                                                                                                                             
abstract_call_method_with_const_args at ./compiler/abstractinterpretation.jl:934                                                                                                                   
abstract_call_method_with_const_args at ./compiler/abstractinterpretation.jl:890                                                                                                                   
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:160                                                                                                                               
abstract_call_known at ./compiler/abstractinterpretation.jl:1842                                                                                                                                   
unknown function (ip: 0xe6772bb9)                                                                                                                                                                  
_jl_invoke at /data/vtjnash/julia/src/gf.c:2428                                                                                                                                                    
ijl_invoke at /data/vtjnash/julia/src/gf.c:2454                                                                                                                                                    
unknown function (ip: 0xe834ece5)                                                                                                                                                                  
unknown function (ip: 0xe834ec4b)                                                                                                                                                                  
abstract_call at ./compiler/abstractinterpretation.jl:1913                                                                                                                                         
abstract_call at ./compiler/abstractinterpretation.jl:1892                                                                                                                                         
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2043                                                                                                                          
abstract_eval_statement at ./compiler/abstractinterpretation.jl:2258                                                                                                                               
abstract_eval_basic_statement at ./compiler/abstractinterpretation.jl:2459                                                                                                                         
typeinf_local at ./compiler/abstractinterpretation.jl:2634                                                                                                                                         
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2740                                                                                                                                       
_typeinf at ./compiler/typeinfer.jl:232                                                                                                                                                            
typeinf at ./compiler/typeinfer.jl:215                                                                                                                                                             
typeinf_edge at ./compiler/typeinfer.jl:937                                                                                                                                                        
abstract_call_method at ./compiler/abstractinterpretation.jl:613                                                                                                                                   
vtjnash commented 1 year ago

This appears to be a very recent regression (https://github.com/JuliaLang/julia/compare/24cb92d1e94367c5ef758545b69133ded4559763...1afa368a425b9cd940f9568d602844ae9fda798d)