EnzymeAD / Enzyme.jl

Julia bindings for the Enzyme automatic differentiator
https://enzyme.mit.edu
MIT License
455 stars 63 forks source link

Enzyme compilation fails with DiffEq ODE solves #1914

Closed MasonProtter closed 1 month ago

MasonProtter commented 1 month ago

Here's @ChrisRackauckas's MWE from Slack, though I get a different error message than him:

(jl_fqJRlD) pkg> st
Status `/tmp/jl_fqJRlD/Project.toml`
  [7da242da] Enzyme v0.13.4
  [b1df2697] OrdinaryDiffEqTsit5 v1.1.0
  [90137ffa] StaticArrays v1.9.7

julia> versioninfo()
Julia Version 1.11.0-rc4
Commit b4b9add84db (2024-09-25 11:03 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 7840U w/ Radeon  780M Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver4)
Threads: 8 default, 0 interactive, 4 GC (on 16 virtual cores)
Environment:
  JULIA_NUM_THREADS = 8
  JULIA_EDITOR = emacsclient
using Enzyme, OrdinaryDiffEqTsit5, StaticArrays

function lorenz!(du, u, p, t)
    du[1] = 10.0(u[2] - u[1])
    du[2] = u[1] * (28.0 - u[3]) - u[2]
    du[3] = u[1] * u[2] - (8 / 3) * u[3]
end

const _saveat =  SA[0.0,0.25,0.5,0.75,1.0,1.25,1.5,1.75,2.0,2.25,2.5,2.75,3.0]

function f(y::Array{Float64}, u0::Array{Float64})
    tspan = (0.0, 3.0)
    prob = ODEProblem{true, SciMLBase.FullSpecialize}(lorenz!, u0, tspan)
    sol = DiffEqBase.solve(prob, Tsit5(), saveat = _saveat, sensealg = DiffEqBase.SensitivityADPassThrough())
    y .= sol[1,:]
    return nothing
end;
u0 = [1.0; 0.0; 0.0]
d_u0 = zeros(3)
y  = zeros(13)
dy = zeros(13)

Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0))
ERROR: Enzyme compilation failed.
Current scope: 
define internal fastcc nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Pointer, [-1,8,-1]:Integer}" {} addrspace(10)* @julia_workqueue_for_42279(i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="139911766231024" "enzymejl_parmtype_ref"="0" %0) unnamed_addr #92 !dbg !2583 {
top:
  %phic = alloca {} addrspace(10)*, align 8
  %phic1 = alloca {} addrspace(10)*, align 8
  %1 = alloca [1 x [2 x i64]], align 8
  %pgcstack = call {}*** @julia.get_pgcstack()
  store {} addrspace(10)* null, {} addrspace(10)** %phic1, align 8, !noalias !448
  store {} addrspace(10)* null, {} addrspace(10)** %phic, align 8, !noalias !448
  %current_task281 = getelementptr inbounds {}**, {}*** %pgcstack, i64 -14
  %2 = bitcast {}*** %current_task281 to {}*
  %ptls_field82 = getelementptr inbounds {}**, {}*** %pgcstack, i64 2
  %3 = bitcast {}*** %ptls_field82 to i64***
  %ptls_load8384 = load i64**, i64*** %3, align 8, !tbaa !206
  %4 = getelementptr inbounds i64*, i64** %ptls_load8384, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !210
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint), !dbg !2584
  fence syncscope("singlethread") seq_cst
  %5 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 139911763590560 to {} addrspace(10)**) unordered, align 32, !dbg !2585, !tbaa !463, !alias.scope !466, !noalias !467
  %.not = icmp eq {} addrspace(10)* %5, null, !dbg !2585
  br i1 %.not, label %err, label %ok, !dbg !2585

L9:                                               ; preds = %ok
  %6 = add i64 %0, -1, !dbg !2586
  %.not86 = icmp ult i64 %6, %118, !dbg !2595
  br i1 %.not86, label %L19, label %L45, !dbg !2592

L19:                                              ; preds = %L9
  %7 = bitcast {} addrspace(10)* %5 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !2597
  %8 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %7 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !2597
  %9 = bitcast {} addrspace(10)* %5 to {} addrspace(10)** addrspace(10)*, !dbg !2597
  %10 = addrspacecast {} addrspace(10)** addrspace(10)* %9 to {} addrspace(10)** addrspace(11)*, !dbg !2597
  %11 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %10, align 8, !dbg !2597, !tbaa !514, !alias.scope !466, !noalias !467
  %12 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %8, i64 0, i32 1, !dbg !2597
  %13 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %12, align 8, !dbg !2597, !tbaa !514, !alias.scope !466, !noalias !467, !dereferenceable_or_null !541, !align !542
  %14 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %13, {} addrspace(10)** %11), !dbg !2600
  %15 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %14, i64 %6, !dbg !2600
  %16 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %15 unordered, align 8, !dbg !2600, !tbaa !646, !alias.scope !466, !noalias !467
  %.not105 = icmp eq {} addrspace(10)* %16, null, !dbg !2600
  br i1 %.not105, label %L45, label %common.ret, !dbg !2594

common.ret:                                       ; preds = %L19, %L271
  %common.ret.op = phi {} addrspace(10)* [ %value_phi23, %L271 ], [ %16, %L19 ]
  ret {} addrspace(10)* %common.ret.op, !dbg !2602

L45:                                              ; preds = %L9, %L19, %ok
  %17 = icmp slt i64 %0, 1, !dbg !2603
  br i1 %17, label %L277, label %L47, !dbg !2606

L47:                                              ; preds = %L45
  call fastcc void @julia_lock_42064({} addrspace(10)* noundef nonnull align 128 dereferenceable(8) addrspacecast ({}* inttoptr (i64 139911763590528 to {}*) to {} addrspace(10)*)), !dbg !2607
  store volatile {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911763590528 to {}*) to {} addrspace(10)*), {} addrspace(10)** %phic, align 8, !dbg !2611, !noalias !448
  store volatile {} addrspace(10)* null, {} addrspace(10)** %phic1, align 8, !dbg !2611, !noalias !448
  %18 = call i64 @ijl_excstack_state({}* nonnull %2), !dbg !2611
  %19 = call i32 @julia.except_enter({}* nonnull %2) #258, !dbg !2611
  %.not91 = icmp eq i32 %19, 0, !dbg !2611
  br i1 %.not91, label %try, label %catch_pop, !dbg !2611

L64:                                              ; preds = %ccall
  %20 = load i64, i64 addrspace(11)* %123, align 8, !dbg !2612, !tbaa !514, !alias.scope !466, !noalias !467
  %21 = add i64 %20, -1, !dbg !2617
  %22 = add i64 %21, %126, !dbg !2619
  %.not95 = icmp eq i64 %22, 0, !dbg !2620
  br i1 %.not95, label %L72, label %L74, !dbg !2620

L72:                                              ; preds = %L64
  %23 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 139911740245936 to {} addrspace(10)**) unordered, align 16, !dbg !2624, !tbaa !210, !alias.scope !479, !noalias !480
  %.not96 = icmp eq {} addrspace(10)* %23, null, !dbg !2624
  br i1 %.not96, label %fail8, label %L76, !dbg !2624

L74:                                              ; preds = %L64
  %24 = call {} addrspace(10)* @jl_alloc_genericmemory({} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911740245904 to {}*) to {} addrspace(10)*), i64 %22), !dbg !2625
  br label %L76, !dbg !2625

L76:                                              ; preds = %L72, %L74
  %25 = phi {} addrspace(10)* [ %24, %L74 ], [ %23, %L72 ]
  %26 = bitcast {} addrspace(10)* %25 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !2626
  %27 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %26 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !2626
  %28 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %27, i64 0, i32 1, !dbg !2626
  %29 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %28, align 8, !dbg !2626, !tbaa !210, !alias.scope !479, !noalias !480, !nonnull !205
  %30 = call noalias nonnull align 8 dereferenceable(24) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 24, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911717334432 to {}*) to {} addrspace(10)*)) #259, !dbg !2628
  %31 = bitcast {} addrspace(10)* %30 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !2628
  %32 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %31 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !2628
  %.repack = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %32, i64 0, i32 0, !dbg !2628
  store {} addrspace(10)** %29, {} addrspace(10)** addrspace(11)* %.repack, align 8, !dbg !2628, !tbaa !485, !alias.scope !488, !noalias !489
  %.repack97 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %32, i64 0, i32 1, !dbg !2628
  store {} addrspace(10)* %25, {} addrspace(10)* addrspace(11)* %.repack97, align 8, !dbg !2628, !tbaa !485, !alias.scope !488, !noalias !489
  %33 = bitcast {} addrspace(10)* %30 to i8 addrspace(10)*, !dbg !2628
  %34 = addrspacecast i8 addrspace(10)* %33 to i8 addrspace(11)*, !dbg !2628
  %35 = getelementptr inbounds i8, i8 addrspace(11)* %34, i64 16, !dbg !2628
  %36 = bitcast i8 addrspace(11)* %35 to i64 addrspace(11)*, !dbg !2628
  store i64 %22, i64 addrspace(11)* %36, align 8, !dbg !2628, !tbaa !490, !alias.scope !488, !noalias !489
  %.not99 = icmp eq i64 %20, 0, !dbg !2629
  br i1 %.not99, label %L176, label %L87, !dbg !2631

L87:                                              ; preds = %L76
  %37 = icmp slt i64 %20, 1, !dbg !2636
  br i1 %37, label %L171, label %L91, !dbg !2638

L91:                                              ; preds = %L87
  %.sroa.057.0..sroa_idx = getelementptr inbounds [1 x [2 x i64]], [1 x [2 x i64]]* %1, i64 0, i64 0, i64 0, !dbg !2639
  store i64 1, i64* %.sroa.057.0..sroa_idx, align 8, !dbg !2639, !tbaa !528, !alias.scope !530, !noalias !531
  %.sroa.258.0..sroa_idx59 = getelementptr inbounds [1 x [2 x i64]], [1 x [2 x i64]]* %1, i64 0, i64 0, i64 1, !dbg !2639
  store i64 %20, i64* %.sroa.258.0..sroa_idx59, align 8, !dbg !2639, !tbaa !528, !alias.scope !530, !noalias !531
  %.not103 = icmp ult i64 %21, %22, !dbg !2641
  br i1 %.not103, label %L164, label %L116, !dbg !2645

L116:                                             ; preds = %L91
  %38 = addrspacecast [1 x [2 x i64]]* %1 to [1 x [2 x i64]] addrspace(11)*, !dbg !2645
  call fastcc void @julia_throw_boundserror_42302({} addrspace(10)* noundef nonnull align 8 dereferenceable(24) %30, [1 x [2 x i64]] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %38) #260, !dbg !2645
  unreachable, !dbg !2645

L164:                                             ; preds = %L91
  %39 = bitcast {} addrspace(10)* %119 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !2646
  %40 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %39 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !2646
  %41 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %40, i64 0, i32 1, !dbg !2646
  %42 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %41, align 8, !dbg !2646, !tbaa !514, !alias.scope !466, !noalias !467, !dereferenceable_or_null !541, !align !542
  %43 = bitcast {} addrspace(10)* %119 to {} addrspace(10)** addrspace(10)*, !dbg !2646
  %44 = addrspacecast {} addrspace(10)** addrspace(10)* %43 to {} addrspace(10)** addrspace(11)*, !dbg !2646
  %45 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %44, align 8, !dbg !2646, !tbaa !514, !alias.scope !466, !noalias !467
  %46 = ptrtoint {} addrspace(10)** %29 to i64, !dbg !2647
  %47 = ptrtoint {} addrspace(10)** %45 to i64, !dbg !2647
  %48 = load atomic void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)*, void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)** bitcast (void ()** @jlplt_jl_genericmemory_copyto_41431_got to void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)**) unordered, align 8, !dbg !2647
  call void %48({} addrspace(10)* nonnull %25, i64 %46, {} addrspace(10)* %42, i64 %47, i64 %20), !dbg !2647
  br label %L176, !dbg !2650

L171:                                             ; preds = %L87
  call fastcc void @julia__throw_argerror_41463({} addrspace(10)* nofree noundef nonnull align 32 addrspacecast ({}* inttoptr (i64 139911822940704 to {}*) to {} addrspace(10)*)) #260, !dbg !2638
  unreachable, !dbg !2638

L176:                                             ; preds = %L164, %L76
  store atomic {} addrspace(10)* %30, {} addrspace(10)** inttoptr (i64 139911763590560 to {} addrspace(10)**) release, align 32, !dbg !2614, !tbaa !463, !alias.scope !466, !noalias !509
  call void ({} addrspace(10)*, ...) @julia.write_barrier({} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911763590560 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull align 8 dereferenceable(24) %30) #261, !dbg !2614
  br label %L186, !dbg !2614

L180:                                             ; preds = %ccall
  %49 = call fastcc [1 x {} addrspace(10)*] @julia_AssertionError_41652({} addrspace(10)* nofree noundef nonnull readonly align 16 addrspacecast ({}* inttoptr (i64 139911781950000 to {}*) to {} addrspace(10)*)), !dbg !2651
  %50 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911752387120 to {}*) to {} addrspace(10)*)) #259, !dbg !2651
  %51 = bitcast {} addrspace(10)* %50 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !2651
  %52 = extractvalue [1 x {} addrspace(10)*] %49, 0, !dbg !2651
  %53 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %51, i64 0, i64 0, !dbg !2651
  store {} addrspace(10)* %52, {} addrspace(10)* addrspace(10)* %53, align 8, !dbg !2651, !tbaa !1017, !alias.scope !466, !noalias !509
  %54 = addrspacecast {} addrspace(10)* %50 to {} addrspace(12)*, !dbg !2651
  call void @ijl_throw({} addrspace(12)* %54), !dbg !2651
  unreachable, !dbg !2651

L186:                                             ; preds = %ok7, %L176
  %.pre-phi.in = phi {} addrspace(10)* [ %119, %ok7 ], [ %30, %L176 ]
  %55 = phi i64 [ %124, %ok7 ], [ %22, %L176 ], !dbg !2652
  %56 = add nsw i64 %0, -1, !dbg !2663
  %.not100 = icmp ult i64 %56, %55, !dbg !2665
  br i1 %.not100, label %L196, label %L186.L204_crit_edge, !dbg !2661

L186.L204_crit_edge:                              ; preds = %L186
  %.phi.trans.insert = bitcast {} addrspace(10)* %.pre-phi.in to {} addrspace(10)** addrspace(10)*
  %.phi.trans.insert106 = addrspacecast {} addrspace(10)** addrspace(10)* %.phi.trans.insert to {} addrspace(10)** addrspace(11)*
  %.pre = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %.phi.trans.insert106, align 8, !dbg !2666, !tbaa !485, !alias.scope !488, !noalias !575
  %.phi.trans.insert107 = bitcast {} addrspace(10)* %.pre-phi.in to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*
  %.phi.trans.insert108 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %.phi.trans.insert107 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*
  %.phi.trans.insert109 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %.phi.trans.insert108, i64 0, i32 1
  %.pre110 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %.phi.trans.insert109, align 8, !dbg !2666, !tbaa !485, !alias.scope !488, !noalias !575
  %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !2667
  br label %L204, !dbg !2661

L196:                                             ; preds = %L186
  %57 = bitcast {} addrspace(10)* %.pre-phi.in to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !2670
  %58 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %57 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !2670
  %59 = bitcast {} addrspace(10)* %.pre-phi.in to {} addrspace(10)** addrspace(10)*, !dbg !2670
  %60 = addrspacecast {} addrspace(10)** addrspace(10)* %59 to {} addrspace(10)** addrspace(11)*, !dbg !2670
  %61 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %60, align 8, !dbg !2670, !tbaa !485, !alias.scope !488, !noalias !575
  %62 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %58, i64 0, i32 1, !dbg !2670
  %63 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %62, align 8, !dbg !2670, !tbaa !485, !alias.scope !488, !noalias !575, !dereferenceable_or_null !541, !align !542
  %64 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %63, {} addrspace(10)** %61), !dbg !2672
  %65 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %64, i64 %56, !dbg !2672
  %66 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %65 unordered, align 8, !dbg !2672, !tbaa !646, !alias.scope !466, !noalias !467
  %.not104 = icmp eq {} addrspace(10)* %66, null, !dbg !2672
  br i1 %.not104, label %L204, label %pass19, !dbg !2662

L204:                                             ; preds = %L186.L204_crit_edge, %L196
  %nodecayed..pre-phi115 = phi {} addrspace(10)* , !dbg !2667
  %nodecayedoff..pre-phi115 = phi i64 , !dbg !2667
  %.pre-phi115 = phi {} addrspace(10)* addrspace(13)* [ %.pre114, %L186.L204_crit_edge ], [ %64, %L196 ], !dbg !2667
  %67 = phi {} addrspace(10)* [ %.pre110, %L186.L204_crit_edge ], [ %63, %L196 ], !dbg !2666
  %68 = call noalias nonnull align 8 dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 16, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911753311264 to {}*) to {} addrspace(10)*)) #259, !dbg !2673
  %69 = bitcast {} addrspace(10)* %68 to {} addrspace(10)* addrspace(10)*, !dbg !2673
  %70 = addrspacecast {} addrspace(10)* addrspace(10)* %69 to {} addrspace(10)* addrspace(11)*, !dbg !2673
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %70, align 8, !dbg !2673, !tbaa !557, !alias.scope !466, !noalias !509
  %71 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %70, i64 1, !dbg !2673
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %71, align 8, !dbg !2673, !tbaa !557, !alias.scope !466, !noalias !509
  %72 = load {}*, {}** @jl_nothing, align 8, !dbg !2673, !tbaa !210, !alias.scope !479, !noalias !480, !nonnull !205
  %73 = addrspacecast {}* %72 to {} addrspace(10)*, !dbg !2673
  store atomic {} addrspace(10)* %73, {} addrspace(10)* addrspace(11)* %70 release, align 8, !dbg !2673, !tbaa !557, !alias.scope !466, !noalias !509
  %74 = bitcast {} addrspace(10)* %68 to i8 addrspace(10)*, !dbg !2673
  %75 = addrspacecast i8 addrspace(10)* %74 to i8 addrspace(11)*, !dbg !2673
  %76 = getelementptr inbounds i8, i8 addrspace(11)* %75, i64 8, !dbg !2673
  %77 = bitcast i8 addrspace(11)* %76 to {} addrspace(10)* addrspace(11)*, !dbg !2673
  store atomic {} addrspace(10)* %73, {} addrspace(10)* addrspace(11)* %77 release, align 8, !dbg !2673, !tbaa !557, !alias.scope !466, !noalias !509
  %78 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911711336800 to {}*) to {} addrspace(10)*)) #259, !dbg !2677
  %79 = bitcast {} addrspace(10)* %78 to i64 addrspace(10)*, !dbg !2677
  %80 = addrspacecast i64 addrspace(10)* %79 to i64 addrspace(11)*, !dbg !2677
  store i64 0, i64 addrspace(11)* %80, align 8, !dbg !2677, !tbaa !557, !alias.scope !466, !noalias !509
  %81 = call noalias nonnull align 8 dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 16, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911740245440 to {}*) to {} addrspace(10)*)) #259, !dbg !2675
  %82 = bitcast {} addrspace(10)* %81 to {} addrspace(10)* addrspace(10)*, !dbg !2675
  %83 = addrspacecast {} addrspace(10)* addrspace(10)* %82 to {} addrspace(10)* addrspace(11)*, !dbg !2675
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %83, align 8, !dbg !2675, !tbaa !557, !alias.scope !466, !noalias !509
  %84 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %83, i64 1, !dbg !2675
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %84, align 8, !dbg !2675, !tbaa !557, !alias.scope !466, !noalias !509
  store atomic {} addrspace(10)* %68, {} addrspace(10)* addrspace(11)* %83 release, align 8, !dbg !2675, !tbaa !557, !alias.scope !466, !noalias !509
  %85 = bitcast {} addrspace(10)* %81 to i8 addrspace(10)*, !dbg !2675
  %86 = addrspacecast i8 addrspace(10)* %85 to i8 addrspace(11)*, !dbg !2675
  %87 = getelementptr inbounds i8, i8 addrspace(11)* %86, i64 8, !dbg !2675
  %88 = bitcast i8 addrspace(11)* %87 to {} addrspace(10)* addrspace(11)*, !dbg !2675
  store atomic {} addrspace(10)* %78, {} addrspace(10)* addrspace(11)* %88 release, align 8, !dbg !2675, !tbaa !557, !alias.scope !466, !noalias !509
  %89 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %.pre-phi115, i64 %56, !dbg !2667
  %90 = bitcast {} addrspace(10)* %67 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !2667
  %91 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %90 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !2667
  %92 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %91, i64 0, i32 1, !dbg !2667
  %93 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %92, align 8, !dbg !2667, !tbaa !833, !alias.scope !488, !noalias !575, !nonnull !205
  %94 = bitcast {} addrspace(10)* %67 to {} addrspace(10)* addrspace(10)*, !dbg !2667
  %95 = addrspacecast {} addrspace(10)* addrspace(10)* %94 to {} addrspace(10)* addrspace(11)*, !dbg !2667
  %96 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %95, i64 2, !dbg !2667
  %97 = addrspacecast {} addrspace(10)** %93 to {} addrspace(10)* addrspace(11)*, !dbg !2667
  %.not101 = icmp eq {} addrspace(10)* addrspace(11)* %96, %97, !dbg !2667
  br i1 %.not101, label %guard_exit, label %guard_pass, !dbg !2667

L250:                                             ; preds = %catch_pop, %pass19
  %value_phi21 = phi {} addrspace(10)* [ addrspacecast ({}* inttoptr (i64 139911763590528 to {}*) to {} addrspace(10)*), %pass19 ], [ %phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0., %catch_pop ]
  %value_phi23 = phi {} addrspace(10)* [ %135, %pass19 ], [ null, %catch_pop ]
  %98 = bitcast {} addrspace(10)* %value_phi21 to i64 addrspace(10)*, !dbg !2679
  %99 = addrspacecast i64 addrspace(10)* %98 to i64 addrspace(11)*, !dbg !2679
  %100 = atomicrmw xchg i64 addrspace(11)* %99, i64 0 release, align 8, !dbg !2679, !tbaa !557, !alias.scope !466, !noalias !467
  %.not88 = icmp eq i64 %100, 0, !dbg !2684
  br i1 %.not88, label %L257, label %L259, !dbg !2681

L257:                                             ; preds = %L250
  call fastcc void @julia_error_42002({} addrspace(10)* nofree noundef nonnull align 16 addrspacecast ({}* inttoptr (i64 139911822199632 to {}*) to {} addrspace(10)*)) #260, !dbg !2685
  unreachable, !dbg !2685

L259:                                             ; preds = %L250
  %101 = bitcast {}*** %ptls_field82 to i32**, !dbg !2686
  %ptls_load288990 = load i32*, i32** %101, align 8, !dbg !2686, !tbaa !206
  %102 = getelementptr inbounds i32, i32* %ptls_load288990, i64 8, !dbg !2686
  %103 = load i32, i32* %102, align 4, !dbg !2686
  %104 = call i32 @llvm.usub.sat.i32(i32 %103, i32 1), !dbg !2686
  store i32 %104, i32* %102, align 4, !dbg !2686, !noalias !448
  %105 = load atomic i32, i32* inttoptr (i64 139912038249184 to i32*) monotonic, align 32, !dbg !2689, !tbaa !566, !alias.scope !466, !noalias !467
  %106 = icmp eq i32 %105, 0, !dbg !2690
  br i1 %106, label %L271, label %L266, !dbg !2689

L266:                                             ; preds = %L259
  %107 = load atomic void (i64)*, void (i64)** bitcast (void ()** @jlplt_jl_gc_run_pending_finalizers_42040_got to void (i64)**) unordered, align 8, !dbg !2694
  call void %107(i64 0), !dbg !2694
  br label %L271, !dbg !2694

L271:                                             ; preds = %L266, %L259
  br i1 %.not91, label %common.ret, label %L273, !dbg !2683

L273:                                             ; preds = %L271
  call fastcc void @julia_rethrow_42060() #260, !dbg !2683
  unreachable, !dbg !2683

L277:                                             ; preds = %L45
  %108 = call fastcc [1 x {} addrspace(10)*] @julia_AssertionError_41652({} addrspace(10)* nofree noundef nonnull readonly align 16 addrspacecast ({}* inttoptr (i64 139911781950032 to {}*) to {} addrspace(10)*)), !dbg !2606
  %109 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 139911752387120 to {}*) to {} addrspace(10)*)) #259, !dbg !2606
  %110 = bitcast {} addrspace(10)* %109 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !2606
  %111 = extractvalue [1 x {} addrspace(10)*] %108, 0, !dbg !2606
  %112 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %110, i64 0, i64 0, !dbg !2606
  store {} addrspace(10)* %111, {} addrspace(10)* addrspace(10)* %112, align 8, !dbg !2606, !tbaa !1017, !alias.scope !466, !noalias !509
  %113 = addrspacecast {} addrspace(10)* %109 to {} addrspace(12)*, !dbg !2606
  call void @ijl_throw({} addrspace(12)* %113), !dbg !2606
  unreachable, !dbg !2606

err:                                              ; preds = %top
  call void @ijl_undefined_var_error({} addrspace(12)* addrspacecast ({}* inttoptr (i64 139911913889312 to {}*) to {} addrspace(12)*), {} addrspace(12)* addrspacecast ({}* inttoptr (i64 139911761460368 to {}*) to {} addrspace(12)*)), !dbg !2585
  unreachable, !dbg !2585

ok:                                               ; preds = %top
  %114 = bitcast {} addrspace(10)* %5 to i8 addrspace(10)*, !dbg !2695
  %115 = addrspacecast i8 addrspace(10)* %114 to i8 addrspace(11)*, !dbg !2695
  %116 = getelementptr inbounds i8, i8 addrspace(11)* %115, i64 16, !dbg !2695
  %117 = bitcast i8 addrspace(11)* %116 to i64 addrspace(11)*, !dbg !2695
  %118 = load i64, i64 addrspace(11)* %117, align 8, !dbg !2695, !tbaa !514, !alias.scope !466, !noalias !467
  %.not85 = icmp slt i64 %118, %0, !dbg !2696
  br i1 %.not85, label %L45, label %L9, !dbg !2594

try:                                              ; preds = %L47
  %119 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 139911763590560 to {} addrspace(10)**) unordered, align 32, !dbg !2700, !tbaa !463, !alias.scope !466, !noalias !467
  %.not92 = icmp eq {} addrspace(10)* %119, null, !dbg !2700
  br i1 %.not92, label %err6, label %ok7, !dbg !2700

catch_pop:                                        ; preds = %L47
  call void @ijl_pop_handler({}* nonnull %2, i32 1) #261, !dbg !2611
  %phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0. = load volatile {} addrspace(10)*, {} addrspace(10)** %phic, align 8, !dbg !2616, !nonnull !205, !dereferenceable !542, !align !542
  %phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0. = load volatile {} addrspace(10)*, {} addrspace(10)** %phic1, align 8, !dbg !2616, !nonnull !205
  br label %L250, !dbg !2616

err6:                                             ; preds = %try
  call void @ijl_undefined_var_error({} addrspace(12)* addrspacecast ({}* inttoptr (i64 139911913889312 to {}*) to {} addrspace(12)*), {} addrspace(12)* addrspacecast ({}* inttoptr (i64 139911761460368 to {}*) to {} addrspace(12)*)), !dbg !2700
  unreachable, !dbg !2700

ok7:                                              ; preds = %try
  %120 = bitcast {} addrspace(10)* %119 to i8 addrspace(10)*, !dbg !2701
  %121 = addrspacecast i8 addrspace(10)* %120 to i8 addrspace(11)*, !dbg !2701
  %122 = getelementptr inbounds i8, i8 addrspace(11)* %121, i64 16, !dbg !2701
  %123 = bitcast i8 addrspace(11)* %122 to i64 addrspace(11)*, !dbg !2701
  %124 = load i64, i64 addrspace(11)* %123, align 8, !dbg !2701, !tbaa !514, !alias.scope !466, !noalias !467
  %.not93 = icmp slt i64 %124, %0, !dbg !2703
  br i1 %.not93, label %ccall, label %L186, !dbg !2702

ccall:                                            ; preds = %ok7
  %125 = load atomic i32, i32* inttoptr (i64 139912047759464 to i32*) acquire, align 8, !dbg !2704, !tbaa !566, !alias.scope !466, !noalias !467
  %126 = sext i32 %125 to i64, !dbg !2708
  %.not94 = icmp slt i64 %126, %0, !dbg !2712
  br i1 %.not94, label %L180, label %L64, !dbg !2651

fail8:                                            ; preds = %L72
  %127 = load {}*, {}** @jl_undefref_exception, align 8, !dbg !2624, !tbaa !210, !alias.scope !479, !noalias !480, !nonnull !205
  %128 = addrspacecast {}* %127 to {} addrspace(12)*, !dbg !2624
  call void @ijl_throw({} addrspace(12)* %128), !dbg !2624
  unreachable, !dbg !2624

guard_pass:                                       ; preds = %L204
  %129 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %91, i64 1, !dbg !2667
  %130 = bitcast { i64, {} addrspace(10)** } addrspace(11)* %129 to {} addrspace(10)* addrspace(11)*, !dbg !2667
  %131 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %130, align 8, !dbg !2667, !tbaa !210, !alias.scope !479, !noalias !480
  %132 = icmp eq {} addrspace(10)* %131, null, !dbg !2667
  %133 = select i1 %132, {} addrspace(10)* %67, {} addrspace(10)* %131, !dbg !2667
  br label %guard_exit, !dbg !2667

guard_exit:                                       ; preds = %guard_pass, %L204
  %134 = phi {} addrspace(10)* [ %67, %L204 ], [ %133, %guard_pass ], !dbg !2667
  store atomic {} addrspace(10)* %81, {} addrspace(10)* addrspace(13)* %89 release, align 8, !dbg !2667, !tbaa !646, !alias.scope !466, !noalias !509
  call void ({} addrspace(10)*, ...) @julia.write_barrier({} addrspace(10)* %134, {} addrspace(10)* nonnull %81) #261, !dbg !2667
  br label %pass19, !dbg !2713

pass19:                                           ; preds = %guard_exit, %L196
  %135 = phi {} addrspace(10)* [ %81, %guard_exit ], [ %66, %L196 ], !dbg !2714
  call void @ijl_pop_handler_noexcept({}* nonnull %2, i32 1) #261, !dbg !2716
  br label %L250, !dbg !2716
}

Could not analyze garbage collection behavior of
 inst:   %.pre-phi115 = phi {} addrspace(10)* addrspace(13)* [ %.pre114, %L186.L204_crit_edge ], [ %64, %L196 ], !dbg !340
 v0:   %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !340
 v:   %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !340
 offset: i64 0
 hasload: false

Stacktrace:
 [1] setindex!
   @ ./array.jl:976
 [2] macro expansion
   @ ./task.jl:785
 [3] macro expansion
   @ ./lock.jl:273
 [4] workqueue_for
   @ ./task.jl:777
 [5] multiple call sites
   @ unknown:0

Stacktrace:
  [1] (::Enzyme.Compiler.var"#getparent#19534"{…})(v::LLVM.CallInst, offset::LLVM.ConstantInt, hasload::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler/optimize.jl:996
  [2] nodecayed_phis!(mod::LLVM.Module)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler/optimize.jl:999
  [3] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler/optimize.jl:2482
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{…}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:7904
  [5] codegen
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:7028 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297
  [7] _thunk
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297 [inlined]
  [8] cached_compilation
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9338 [inlined]
  [9] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, ::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…}, ::Val{…}, ::Val{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9470
 [10] #s2064#19730
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9607 [inlined]
 [11] 
    @ Enzyme.Compiler ./none:0
 [12] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:707
 [13] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:473 [inlined]
 [14] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:537 [inlined]
 [15] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{…}}, ::Duplicated{Vector{…}})
    @ Enzyme ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:504
 [16] top-level scope
    @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.
MasonProtter commented 1 month ago

Ah, I see the error message Chris reported if I run on v1.10:

(jl_BPlSL0) pkg> st
Status `/tmp/jl_BPlSL0/Project.toml`
  [7da242da] Enzyme v0.13.4
  [b1df2697] OrdinaryDiffEqTsit5 v1.1.0
  [90137ffa] StaticArrays v1.9.7

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 7840U w/ Radeon  780M Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 8 default, 0 interactive, 4 GC (on 16 virtual cores)
Environment:
  JULIA_NUM_THREADS = 8
  JULIA_EDITOR = emacsclient
julia> Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0));
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
ERROR: Type Array does not have a definite size.
Stacktrace:
  [1] sizeof(x::Type)
    @ Base ./essentials.jl:631
  [2] jl_array_del_end_rev(B::LLVM.IRBuilder, orig::LLVM.CallInst, gutils::Enzyme.Compiler.GradientUtils, tape::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/rules/llvmrules.jl:1522
  [3] jl_array_del_end_rev_cfunc(B::Ptr{…}, OrigCI::Ptr{…}, gutils::Ptr{…}, tape::Ptr{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/rules/llvmrules.jl:48
  [4] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constant_args::Vector{…}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDerivativeMode, runtimeActivity::Bool, width::Int64, additionalArg::Ptr{…}, forceAnonymousTape::Bool, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{…}, augmented::Ptr{…}, atomicAdd::Bool)
    @ Enzyme.API ~/.julia/packages/Enzyme/HXYPU/src/api.jl:253
  [5] enzyme!(job::GPUCompiler.CompilerJob{…}, mod::LLVM.Module, primalf::LLVM.Function, TT::Type, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, wrap::Bool, modifiedBetween::Tuple{…}, returnPrimal::Bool, expectedTapeType::Type, loweredArgs::Set{…}, boxedArgs::Set{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:5096
  [6] codegen(output::Symbol, job::GPUCompiler.CompilerJob{…}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:8189
  [7] codegen
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:7028 [inlined]
  [8] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297
  [9] _thunk
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297 [inlined]
 [10] cached_compilation
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9338 [inlined]
 [11] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, ::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…}, ::Val{…}, ::Val{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9470
 [12] #s2064#19667
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9607 [inlined]
 [13] 
    @ Enzyme.Compiler ./none:0
 [14] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:602
 [15] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:473 [inlined]
 [16] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:537 [inlined]
 [17] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{…}}, ::Duplicated{Vector{…}})
    @ Enzyme ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:504
 [18] top-level scope
    @ REPL[11]:1
Some type information was truncated. Use `show(err)` to see complete types.
wsmoses commented 1 month ago

@MasonProtter does this resolve? https://github.com/EnzymeAD/Enzyme.jl/pull/1915

MasonProtter commented 1 month ago

@wsmoses nope

wsmoses commented 1 month ago

what's the present error message?

MasonProtter commented 1 month ago

v1.11:

julia> Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0))
ERROR: Enzyme compilation failed.
Current scope: 
define internal fastcc nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Pointer, [-1,8,-1]:Integer}" {} addrspace(10)* @julia_workqueue_for_38076(i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="140701148923888" "enzymejl_parmtype_ref"="0" %0) unnamed_addr #112 !dbg !3167 {
top:
  %phic = alloca {} addrspace(10)*, align 8
  %phic1 = alloca {} addrspace(10)*, align 8
  %1 = alloca [1 x [2 x i64]], align 8
  %pgcstack = call {}*** @julia.get_pgcstack()
  store {} addrspace(10)* null, {} addrspace(10)** %phic1, align 8, !noalias !594
  store {} addrspace(10)* null, {} addrspace(10)** %phic, align 8, !noalias !594
  %current_task281 = getelementptr inbounds {}**, {}*** %pgcstack, i64 -14
  %2 = bitcast {}*** %current_task281 to {}*
  %ptls_field82 = getelementptr inbounds {}**, {}*** %pgcstack, i64 2
  %3 = bitcast {}*** %ptls_field82 to i64***
  %ptls_load8384 = load i64**, i64*** %3, align 8, !tbaa !206
  %4 = getelementptr inbounds i64*, i64** %ptls_load8384, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !210
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint), !dbg !3168
  fence syncscope("singlethread") seq_cst
  %5 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 140701146283424 to {} addrspace(10)**) unordered, align 32, !dbg !3169, !tbaa !1316, !alias.scope !263, !noalias !264
  %.not = icmp eq {} addrspace(10)* %5, null, !dbg !3169
  br i1 %.not, label %err, label %ok, !dbg !3169

L9:                                               ; preds = %ok
  %6 = add i64 %0, -1, !dbg !3170
  %.not86 = icmp ult i64 %6, %118, !dbg !3179
  br i1 %.not86, label %L19, label %L45, !dbg !3176

L19:                                              ; preds = %L9
  %7 = bitcast {} addrspace(10)* %5 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !3181
  %8 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %7 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !3181
  %9 = bitcast {} addrspace(10)* %5 to {} addrspace(10)** addrspace(10)*, !dbg !3181
  %10 = addrspacecast {} addrspace(10)** addrspace(10)* %9 to {} addrspace(10)** addrspace(11)*, !dbg !3181
  %11 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %10, align 8, !dbg !3181, !tbaa !371, !alias.scope !263, !noalias !264
  %12 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %8, i64 0, i32 1, !dbg !3181
  %13 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %12, align 8, !dbg !3181, !tbaa !371, !alias.scope !263, !noalias !264, !dereferenceable_or_null !328, !align !329
  %14 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %13, {} addrspace(10)** %11), !dbg !3184
  %15 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %14, i64 %6, !dbg !3184
  %16 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %15 unordered, align 8, !dbg !3184, !tbaa !2019, !alias.scope !263, !noalias !264
  %.not105 = icmp eq {} addrspace(10)* %16, null, !dbg !3184
  br i1 %.not105, label %L45, label %common.ret, !dbg !3178

common.ret:                                       ; preds = %L19, %L271
  %common.ret.op = phi {} addrspace(10)* [ %value_phi23, %L271 ], [ %16, %L19 ]
  ret {} addrspace(10)* %common.ret.op, !dbg !3186

L45:                                              ; preds = %L9, %L19, %ok
  %17 = icmp slt i64 %0, 1, !dbg !3187
  br i1 %17, label %L277, label %L47, !dbg !3190

L47:                                              ; preds = %L45
  call fastcc void @julia_lock_37861({} addrspace(10)* noundef nonnull align 128 dereferenceable(8) addrspacecast ({}* inttoptr (i64 140701146283392 to {}*) to {} addrspace(10)*)), !dbg !3191
  store volatile {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701146283392 to {}*) to {} addrspace(10)*), {} addrspace(10)** %phic, align 8, !dbg !3195, !noalias !594
  store volatile {} addrspace(10)* null, {} addrspace(10)** %phic1, align 8, !dbg !3195, !noalias !594
  %18 = call i64 @ijl_excstack_state({}* nonnull %2), !dbg !3195
  %19 = call i32 @julia.except_enter({}* nonnull %2) #258, !dbg !3195
  %.not91 = icmp eq i32 %19, 0, !dbg !3195
  br i1 %.not91, label %try, label %catch_pop, !dbg !3195

L64:                                              ; preds = %ccall
  %20 = load i64, i64 addrspace(11)* %123, align 8, !dbg !3196, !tbaa !371, !alias.scope !263, !noalias !264
  %21 = add i64 %20, -1, !dbg !3201
  %22 = add i64 %21, %126, !dbg !3203
  %.not95 = icmp eq i64 %22, 0, !dbg !3204
  br i1 %.not95, label %L72, label %L74, !dbg !3204

L72:                                              ; preds = %L64
  %23 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 140701122938800 to {} addrspace(10)**) unordered, align 16, !dbg !3208, !tbaa !210, !alias.scope !236, !noalias !237
  %.not96 = icmp eq {} addrspace(10)* %23, null, !dbg !3208
  br i1 %.not96, label %fail8, label %L76, !dbg !3208

L74:                                              ; preds = %L64
  %24 = call {} addrspace(10)* @jl_alloc_genericmemory({} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701122938768 to {}*) to {} addrspace(10)*), i64 %22), !dbg !3209
  br label %L76, !dbg !3209

L76:                                              ; preds = %L72, %L74
  %25 = phi {} addrspace(10)* [ %24, %L74 ], [ %23, %L72 ]
  %26 = bitcast {} addrspace(10)* %25 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !3210
  %27 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %26 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !3210
  %28 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %27, i64 0, i32 1, !dbg !3210
  %29 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %28, align 8, !dbg !3210, !tbaa !210, !alias.scope !236, !noalias !237, !nonnull !205
  %30 = call noalias nonnull align 8 dereferenceable(24) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 24, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701100027296 to {}*) to {} addrspace(10)*)) #259, !dbg !3212
  %31 = bitcast {} addrspace(10)* %30 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !3212
  %32 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %31 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !3212
  %.repack = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %32, i64 0, i32 0, !dbg !3212
  store {} addrspace(10)** %29, {} addrspace(10)** addrspace(11)* %.repack, align 8, !dbg !3212, !tbaa !343, !alias.scope !335, !noalias !345
  %.repack97 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %32, i64 0, i32 1, !dbg !3212
  store {} addrspace(10)* %25, {} addrspace(10)* addrspace(11)* %.repack97, align 8, !dbg !3212, !tbaa !343, !alias.scope !335, !noalias !345
  %33 = bitcast {} addrspace(10)* %30 to i8 addrspace(10)*, !dbg !3212
  %34 = addrspacecast i8 addrspace(10)* %33 to i8 addrspace(11)*, !dbg !3212
  %35 = getelementptr inbounds i8, i8 addrspace(11)* %34, i64 16, !dbg !3212
  %36 = bitcast i8 addrspace(11)* %35 to i64 addrspace(11)*, !dbg !3212
  store i64 %22, i64 addrspace(11)* %36, align 8, !dbg !3212, !tbaa !346, !alias.scope !335, !noalias !345
  %.not99 = icmp eq i64 %20, 0, !dbg !3213
  br i1 %.not99, label %L176, label %L87, !dbg !3215

L87:                                              ; preds = %L76
  %37 = icmp slt i64 %20, 1, !dbg !3220
  br i1 %37, label %L171, label %L91, !dbg !3222

L91:                                              ; preds = %L87
  %.sroa.057.0..sroa_idx = getelementptr inbounds [1 x [2 x i64]], [1 x [2 x i64]]* %1, i64 0, i64 0, i64 0, !dbg !3223
  store i64 1, i64* %.sroa.057.0..sroa_idx, align 8, !dbg !3223, !tbaa !381, !alias.scope !383, !noalias !384
  %.sroa.258.0..sroa_idx59 = getelementptr inbounds [1 x [2 x i64]], [1 x [2 x i64]]* %1, i64 0, i64 0, i64 1, !dbg !3223
  store i64 %20, i64* %.sroa.258.0..sroa_idx59, align 8, !dbg !3223, !tbaa !381, !alias.scope !383, !noalias !384
  %.not103 = icmp ult i64 %21, %22, !dbg !3225
  br i1 %.not103, label %L164, label %L116, !dbg !3229

L116:                                             ; preds = %L91
  %38 = addrspacecast [1 x [2 x i64]]* %1 to [1 x [2 x i64]] addrspace(11)*, !dbg !3229
  call fastcc void @julia_throw_boundserror_38099({} addrspace(10)* noundef nonnull align 8 dereferenceable(24) %30, [1 x [2 x i64]] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %38) #260, !dbg !3229
  unreachable, !dbg !3229

L164:                                             ; preds = %L91
  %39 = bitcast {} addrspace(10)* %119 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !3230
  %40 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %39 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !3230
  %41 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %40, i64 0, i32 1, !dbg !3230
  %42 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %41, align 8, !dbg !3230, !tbaa !371, !alias.scope !263, !noalias !264, !dereferenceable_or_null !328, !align !329
  %43 = bitcast {} addrspace(10)* %119 to {} addrspace(10)** addrspace(10)*, !dbg !3230
  %44 = addrspacecast {} addrspace(10)** addrspace(10)* %43 to {} addrspace(10)** addrspace(11)*, !dbg !3230
  %45 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %44, align 8, !dbg !3230, !tbaa !371, !alias.scope !263, !noalias !264
  %46 = ptrtoint {} addrspace(10)** %29 to i64, !dbg !3231
  %47 = ptrtoint {} addrspace(10)** %45 to i64, !dbg !3231
  %48 = load atomic void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)*, void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)** bitcast (void ()** @jlplt_jl_genericmemory_copyto_37228_got to void ({} addrspace(10)*, i64, {} addrspace(10)*, i64, i64)**) unordered, align 8, !dbg !3231
  call void %48({} addrspace(10)* nonnull %25, i64 %46, {} addrspace(10)* %42, i64 %47, i64 %20), !dbg !3231
  br label %L176, !dbg !3234

L171:                                             ; preds = %L87
  call fastcc void @julia__throw_argerror_37260({} addrspace(10)* nofree noundef nonnull align 32 addrspacecast ({}* inttoptr (i64 140701205633568 to {}*) to {} addrspace(10)*)) #260, !dbg !3222
  unreachable, !dbg !3222

L176:                                             ; preds = %L164, %L76
  store atomic {} addrspace(10)* %30, {} addrspace(10)** inttoptr (i64 140701146283424 to {} addrspace(10)**) release, align 32, !dbg !3198, !tbaa !1316, !alias.scope !263, !noalias !310
  call void ({} addrspace(10)*, ...) @julia.write_barrier({} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701146283424 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull align 8 dereferenceable(24) %30) #261, !dbg !3198
  br label %L186, !dbg !3198

L180:                                             ; preds = %ccall
  %49 = call fastcc [1 x {} addrspace(10)*] @julia_AssertionError_37449({} addrspace(10)* nofree noundef nonnull readonly align 16 addrspacecast ({}* inttoptr (i64 140701164642864 to {}*) to {} addrspace(10)*)), !dbg !3235
  %50 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701135079984 to {}*) to {} addrspace(10)*)) #259, !dbg !3235
  %51 = bitcast {} addrspace(10)* %50 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !3235
  %52 = extractvalue [1 x {} addrspace(10)*] %49, 0, !dbg !3235
  %53 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %51, i64 0, i64 0, !dbg !3235
  store {} addrspace(10)* %52, {} addrspace(10)* addrspace(10)* %53, align 8, !dbg !3235, !tbaa !470, !alias.scope !263, !noalias !310
  %54 = addrspacecast {} addrspace(10)* %50 to {} addrspace(12)*, !dbg !3235
  call void @ijl_throw({} addrspace(12)* %54), !dbg !3235
  unreachable, !dbg !3235

L186:                                             ; preds = %ok7, %L176
  %.pre-phi.in = phi {} addrspace(10)* [ %119, %ok7 ], [ %30, %L176 ]
  %55 = phi i64 [ %124, %ok7 ], [ %22, %L176 ], !dbg !3236
  %56 = add nsw i64 %0, -1, !dbg !3247
  %.not100 = icmp ult i64 %56, %55, !dbg !3249
  br i1 %.not100, label %L196, label %L186.L204_crit_edge, !dbg !3245

L186.L204_crit_edge:                              ; preds = %L186
  %.phi.trans.insert = bitcast {} addrspace(10)* %.pre-phi.in to {} addrspace(10)** addrspace(10)*
  %.phi.trans.insert106 = addrspacecast {} addrspace(10)** addrspace(10)* %.phi.trans.insert to {} addrspace(10)** addrspace(11)*
  %.pre = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %.phi.trans.insert106, align 8, !dbg !3250, !tbaa !343, !alias.scope !335, !noalias !336
  %.phi.trans.insert107 = bitcast {} addrspace(10)* %.pre-phi.in to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*
  %.phi.trans.insert108 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %.phi.trans.insert107 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*
  %.phi.trans.insert109 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %.phi.trans.insert108, i64 0, i32 1
  %.pre110 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %.phi.trans.insert109, align 8, !dbg !3250, !tbaa !343, !alias.scope !335, !noalias !336
  %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !3251
  br label %L204, !dbg !3245

L196:                                             ; preds = %L186
  %57 = bitcast {} addrspace(10)* %.pre-phi.in to { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)*, !dbg !3254
  %58 = addrspacecast { {} addrspace(10)**, {} addrspace(10)* } addrspace(10)* %57 to { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)*, !dbg !3254
  %59 = bitcast {} addrspace(10)* %.pre-phi.in to {} addrspace(10)** addrspace(10)*, !dbg !3254
  %60 = addrspacecast {} addrspace(10)** addrspace(10)* %59 to {} addrspace(10)** addrspace(11)*, !dbg !3254
  %61 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %60, align 8, !dbg !3254, !tbaa !343, !alias.scope !335, !noalias !336
  %62 = getelementptr inbounds { {} addrspace(10)**, {} addrspace(10)* }, { {} addrspace(10)**, {} addrspace(10)* } addrspace(11)* %58, i64 0, i32 1, !dbg !3254
  %63 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %62, align 8, !dbg !3254, !tbaa !343, !alias.scope !335, !noalias !336, !dereferenceable_or_null !328, !align !329
  %64 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %63, {} addrspace(10)** %61), !dbg !3256
  %65 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %64, i64 %56, !dbg !3256
  %66 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %65 unordered, align 8, !dbg !3256, !tbaa !2019, !alias.scope !263, !noalias !264
  %.not104 = icmp eq {} addrspace(10)* %66, null, !dbg !3256
  br i1 %.not104, label %L204, label %pass19, !dbg !3246

L204:                                             ; preds = %L186.L204_crit_edge, %L196
  %nodecayed..pre-phi115 = phi {} addrspace(10)* , !dbg !3251
  %nodecayedoff..pre-phi115 = phi i64 , !dbg !3251
  %.pre-phi115 = phi {} addrspace(10)* addrspace(13)* [ %.pre114, %L186.L204_crit_edge ], [ %64, %L196 ], !dbg !3251
  %67 = phi {} addrspace(10)* [ %.pre110, %L186.L204_crit_edge ], [ %63, %L196 ], !dbg !3250
  %68 = call noalias nonnull align 8 dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 16, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701136004128 to {}*) to {} addrspace(10)*)) #259, !dbg !3257
  %69 = bitcast {} addrspace(10)* %68 to {} addrspace(10)* addrspace(10)*, !dbg !3257
  %70 = addrspacecast {} addrspace(10)* addrspace(10)* %69 to {} addrspace(10)* addrspace(11)*, !dbg !3257
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %70, align 8, !dbg !3257, !tbaa !298, !alias.scope !263, !noalias !310
  %71 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %70, i64 1, !dbg !3257
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %71, align 8, !dbg !3257, !tbaa !298, !alias.scope !263, !noalias !310
  %72 = load {}*, {}** @jl_nothing, align 8, !dbg !3257, !tbaa !210, !alias.scope !236, !noalias !237, !nonnull !205
  %73 = addrspacecast {}* %72 to {} addrspace(10)*, !dbg !3257
  store atomic {} addrspace(10)* %73, {} addrspace(10)* addrspace(11)* %70 release, align 8, !dbg !3257, !tbaa !298, !alias.scope !263, !noalias !310
  %74 = bitcast {} addrspace(10)* %68 to i8 addrspace(10)*, !dbg !3257
  %75 = addrspacecast i8 addrspace(10)* %74 to i8 addrspace(11)*, !dbg !3257
  %76 = getelementptr inbounds i8, i8 addrspace(11)* %75, i64 8, !dbg !3257
  %77 = bitcast i8 addrspace(11)* %76 to {} addrspace(10)* addrspace(11)*, !dbg !3257
  store atomic {} addrspace(10)* %73, {} addrspace(10)* addrspace(11)* %77 release, align 8, !dbg !3257, !tbaa !298, !alias.scope !263, !noalias !310
  %78 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701094029664 to {}*) to {} addrspace(10)*)) #259, !dbg !3261
  %79 = bitcast {} addrspace(10)* %78 to i64 addrspace(10)*, !dbg !3261
  %80 = addrspacecast i64 addrspace(10)* %79 to i64 addrspace(11)*, !dbg !3261
  store i64 0, i64 addrspace(11)* %80, align 8, !dbg !3261, !tbaa !298, !alias.scope !263, !noalias !310
  %81 = call noalias nonnull align 8 dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 16, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701122938304 to {}*) to {} addrspace(10)*)) #259, !dbg !3259
  %82 = bitcast {} addrspace(10)* %81 to {} addrspace(10)* addrspace(10)*, !dbg !3259
  %83 = addrspacecast {} addrspace(10)* addrspace(10)* %82 to {} addrspace(10)* addrspace(11)*, !dbg !3259
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %83, align 8, !dbg !3259, !tbaa !298, !alias.scope !263, !noalias !310
  %84 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %83, i64 1, !dbg !3259
  store {} addrspace(10)* null, {} addrspace(10)* addrspace(11)* %84, align 8, !dbg !3259, !tbaa !298, !alias.scope !263, !noalias !310
  store atomic {} addrspace(10)* %68, {} addrspace(10)* addrspace(11)* %83 release, align 8, !dbg !3259, !tbaa !298, !alias.scope !263, !noalias !310
  %85 = bitcast {} addrspace(10)* %81 to i8 addrspace(10)*, !dbg !3259
  %86 = addrspacecast i8 addrspace(10)* %85 to i8 addrspace(11)*, !dbg !3259
  %87 = getelementptr inbounds i8, i8 addrspace(11)* %86, i64 8, !dbg !3259
  %88 = bitcast i8 addrspace(11)* %87 to {} addrspace(10)* addrspace(11)*, !dbg !3259
  store atomic {} addrspace(10)* %78, {} addrspace(10)* addrspace(11)* %88 release, align 8, !dbg !3259, !tbaa !298, !alias.scope !263, !noalias !310
  %89 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %.pre-phi115, i64 %56, !dbg !3251
  %90 = bitcast {} addrspace(10)* %67 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !3251
  %91 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %90 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !3251
  %92 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %91, i64 0, i32 1, !dbg !3251
  %93 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %92, align 8, !dbg !3251, !tbaa !2206, !alias.scope !335, !noalias !336, !nonnull !205
  %94 = bitcast {} addrspace(10)* %67 to {} addrspace(10)* addrspace(10)*, !dbg !3251
  %95 = addrspacecast {} addrspace(10)* addrspace(10)* %94 to {} addrspace(10)* addrspace(11)*, !dbg !3251
  %96 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %95, i64 2, !dbg !3251
  %97 = addrspacecast {} addrspace(10)** %93 to {} addrspace(10)* addrspace(11)*, !dbg !3251
  %.not101 = icmp eq {} addrspace(10)* addrspace(11)* %96, %97, !dbg !3251
  br i1 %.not101, label %guard_exit, label %guard_pass, !dbg !3251

L250:                                             ; preds = %catch_pop, %pass19
  %value_phi21 = phi {} addrspace(10)* [ addrspacecast ({}* inttoptr (i64 140701146283392 to {}*) to {} addrspace(10)*), %pass19 ], [ %phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0., %catch_pop ]
  %value_phi23 = phi {} addrspace(10)* [ %135, %pass19 ], [ null, %catch_pop ]
  %98 = bitcast {} addrspace(10)* %value_phi21 to i64 addrspace(10)*, !dbg !3263
  %99 = addrspacecast i64 addrspace(10)* %98 to i64 addrspace(11)*, !dbg !3263
  %100 = atomicrmw xchg i64 addrspace(11)* %99, i64 0 release, align 8, !dbg !3263, !tbaa !298, !alias.scope !263, !noalias !264
  %.not88 = icmp eq i64 %100, 0, !dbg !3268
  br i1 %.not88, label %L257, label %L259, !dbg !3265

L257:                                             ; preds = %L250
  call fastcc void @julia_error_37799({} addrspace(10)* nofree noundef nonnull align 16 addrspacecast ({}* inttoptr (i64 140701204892496 to {}*) to {} addrspace(10)*)) #260, !dbg !3269
  unreachable, !dbg !3269

L259:                                             ; preds = %L250
  %101 = bitcast {}*** %ptls_field82 to i32**, !dbg !3270
  %ptls_load288990 = load i32*, i32** %101, align 8, !dbg !3270, !tbaa !206
  %102 = getelementptr inbounds i32, i32* %ptls_load288990, i64 8, !dbg !3270
  %103 = load i32, i32* %102, align 4, !dbg !3270
  %104 = call i32 @llvm.usub.sat.i32(i32 %103, i32 1), !dbg !3270
  store i32 %104, i32* %102, align 4, !dbg !3270, !noalias !594
  %105 = load atomic i32, i32* inttoptr (i64 140701420942048 to i32*) monotonic, align 32, !dbg !3273, !tbaa !261, !alias.scope !263, !noalias !264
  %106 = icmp eq i32 %105, 0, !dbg !3274
  br i1 %106, label %L271, label %L266, !dbg !3273

L266:                                             ; preds = %L259
  %107 = load atomic void (i64)*, void (i64)** bitcast (void ()** @jlplt_jl_gc_run_pending_finalizers_37837_got to void (i64)**) unordered, align 8, !dbg !3278
  call void %107(i64 0), !dbg !3278
  br label %L271, !dbg !3278

L271:                                             ; preds = %L266, %L259
  br i1 %.not91, label %common.ret, label %L273, !dbg !3267

L273:                                             ; preds = %L271
  call fastcc void @julia_rethrow_37857() #260, !dbg !3267
  unreachable, !dbg !3267

L277:                                             ; preds = %L45
  %108 = call fastcc [1 x {} addrspace(10)*] @julia_AssertionError_37449({} addrspace(10)* nofree noundef nonnull readonly align 16 addrspacecast ({}* inttoptr (i64 140701164642896 to {}*) to {} addrspace(10)*)), !dbg !3190
  %109 = call noalias nonnull align 8 dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %2, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 140701135079984 to {}*) to {} addrspace(10)*)) #259, !dbg !3190
  %110 = bitcast {} addrspace(10)* %109 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !3190
  %111 = extractvalue [1 x {} addrspace(10)*] %108, 0, !dbg !3190
  %112 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %110, i64 0, i64 0, !dbg !3190
  store {} addrspace(10)* %111, {} addrspace(10)* addrspace(10)* %112, align 8, !dbg !3190, !tbaa !470, !alias.scope !263, !noalias !310
  %113 = addrspacecast {} addrspace(10)* %109 to {} addrspace(12)*, !dbg !3190
  call void @ijl_throw({} addrspace(12)* %113), !dbg !3190
  unreachable, !dbg !3190

err:                                              ; preds = %top
  call void @ijl_undefined_var_error({} addrspace(12)* addrspacecast ({}* inttoptr (i64 140701296582176 to {}*) to {} addrspace(12)*), {} addrspace(12)* addrspacecast ({}* inttoptr (i64 140701144153232 to {}*) to {} addrspace(12)*)), !dbg !3169
  unreachable, !dbg !3169

ok:                                               ; preds = %top
  %114 = bitcast {} addrspace(10)* %5 to i8 addrspace(10)*, !dbg !3279
  %115 = addrspacecast i8 addrspace(10)* %114 to i8 addrspace(11)*, !dbg !3279
  %116 = getelementptr inbounds i8, i8 addrspace(11)* %115, i64 16, !dbg !3279
  %117 = bitcast i8 addrspace(11)* %116 to i64 addrspace(11)*, !dbg !3279
  %118 = load i64, i64 addrspace(11)* %117, align 8, !dbg !3279, !tbaa !371, !alias.scope !263, !noalias !264
  %.not85 = icmp slt i64 %118, %0, !dbg !3280
  br i1 %.not85, label %L45, label %L9, !dbg !3178

try:                                              ; preds = %L47
  %119 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 140701146283424 to {} addrspace(10)**) unordered, align 32, !dbg !3284, !tbaa !1316, !alias.scope !263, !noalias !264
  %.not92 = icmp eq {} addrspace(10)* %119, null, !dbg !3284
  br i1 %.not92, label %err6, label %ok7, !dbg !3284

catch_pop:                                        ; preds = %L47
  call void @ijl_pop_handler({}* nonnull %2, i32 1) #261, !dbg !3195
  %phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0.phic.0. = load volatile {} addrspace(10)*, {} addrspace(10)** %phic, align 8, !dbg !3200, !nonnull !205, !dereferenceable !329, !align !329
  %phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0.phic1.0. = load volatile {} addrspace(10)*, {} addrspace(10)** %phic1, align 8, !dbg !3200, !nonnull !205
  br label %L250, !dbg !3200

err6:                                             ; preds = %try
  call void @ijl_undefined_var_error({} addrspace(12)* addrspacecast ({}* inttoptr (i64 140701296582176 to {}*) to {} addrspace(12)*), {} addrspace(12)* addrspacecast ({}* inttoptr (i64 140701144153232 to {}*) to {} addrspace(12)*)), !dbg !3284
  unreachable, !dbg !3284

ok7:                                              ; preds = %try
  %120 = bitcast {} addrspace(10)* %119 to i8 addrspace(10)*, !dbg !3285
  %121 = addrspacecast i8 addrspace(10)* %120 to i8 addrspace(11)*, !dbg !3285
  %122 = getelementptr inbounds i8, i8 addrspace(11)* %121, i64 16, !dbg !3285
  %123 = bitcast i8 addrspace(11)* %122 to i64 addrspace(11)*, !dbg !3285
  %124 = load i64, i64 addrspace(11)* %123, align 8, !dbg !3285, !tbaa !371, !alias.scope !263, !noalias !264
  %.not93 = icmp slt i64 %124, %0, !dbg !3287
  br i1 %.not93, label %ccall, label %L186, !dbg !3286

ccall:                                            ; preds = %ok7
  %125 = load atomic i32, i32* inttoptr (i64 140701432139880 to i32*) acquire, align 8, !dbg !3288, !tbaa !261, !alias.scope !263, !noalias !264
  %126 = sext i32 %125 to i64, !dbg !3292
  %.not94 = icmp slt i64 %126, %0, !dbg !3296
  br i1 %.not94, label %L180, label %L64, !dbg !3235

fail8:                                            ; preds = %L72
  %127 = load {}*, {}** @jl_undefref_exception, align 8, !dbg !3208, !tbaa !210, !alias.scope !236, !noalias !237, !nonnull !205
  %128 = addrspacecast {}* %127 to {} addrspace(12)*, !dbg !3208
  call void @ijl_throw({} addrspace(12)* %128), !dbg !3208
  unreachable, !dbg !3208

guard_pass:                                       ; preds = %L204
  %129 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %91, i64 1, !dbg !3251
  %130 = bitcast { i64, {} addrspace(10)** } addrspace(11)* %129 to {} addrspace(10)* addrspace(11)*, !dbg !3251
  %131 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %130, align 8, !dbg !3251, !tbaa !210, !alias.scope !236, !noalias !237
  %132 = icmp eq {} addrspace(10)* %131, null, !dbg !3251
  %133 = select i1 %132, {} addrspace(10)* %67, {} addrspace(10)* %131, !dbg !3251
  br label %guard_exit, !dbg !3251

guard_exit:                                       ; preds = %guard_pass, %L204
  %134 = phi {} addrspace(10)* [ %67, %L204 ], [ %133, %guard_pass ], !dbg !3251
  store atomic {} addrspace(10)* %81, {} addrspace(10)* addrspace(13)* %89 release, align 8, !dbg !3251, !tbaa !2019, !alias.scope !263, !noalias !310
  call void ({} addrspace(10)*, ...) @julia.write_barrier({} addrspace(10)* %134, {} addrspace(10)* nonnull %81) #261, !dbg !3251
  br label %pass19, !dbg !3297

pass19:                                           ; preds = %guard_exit, %L196
  %135 = phi {} addrspace(10)* [ %81, %guard_exit ], [ %66, %L196 ], !dbg !3298
  call void @ijl_pop_handler_noexcept({}* nonnull %2, i32 1) #261, !dbg !3300
  br label %L250, !dbg !3300
}

Could not analyze garbage collection behavior of
 inst:   %.pre-phi115 = phi {} addrspace(10)* addrspace(13)* [ %.pre114, %L186.L204_crit_edge ], [ %64, %L196 ], !dbg !340
 v0:   %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !340
 v:   %.pre114 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %.pre110, {} addrspace(10)** %.pre), !dbg !340
 offset: i64 0
 hasload: false

Stacktrace:
 [1] setindex!
   @ ./array.jl:976
 [2] macro expansion
   @ ./task.jl:785
 [3] macro expansion
   @ ./lock.jl:273
 [4] workqueue_for
   @ ./task.jl:777
 [5] multiple call sites
   @ unknown:0

Stacktrace:
  [1] (::Enzyme.Compiler.var"#getparent#19536"{…})(v::LLVM.CallInst, offset::LLVM.ConstantInt, hasload::Bool)
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler/optimize.jl:996
  [2] nodecayed_phis!(mod::LLVM.Module)
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler/optimize.jl:999
  [3] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler/optimize.jl:2482
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{…}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler.jl:7904
  [5] codegen
    @ ~/Dropbox/Julia/Enzyme/src/compiler.jl:7028 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler.jl:9297
  [7] _thunk
    @ ~/Dropbox/Julia/Enzyme/src/compiler.jl:9297 [inlined]
  [8] cached_compilation
    @ ~/Dropbox/Julia/Enzyme/src/compiler.jl:9338 [inlined]
  [9] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, ::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…}, ::Val{…}, ::Val{…})
    @ Enzyme.Compiler ~/Dropbox/Julia/Enzyme/src/compiler.jl:9470
 [10] #s2064#19732
    @ ~/Dropbox/Julia/Enzyme/src/compiler.jl:9607 [inlined]
 [11] 
    @ Enzyme.Compiler ./none:0
 [12] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:707
 [13] autodiff
    @ ~/Dropbox/Julia/Enzyme/src/Enzyme.jl:473 [inlined]
 [14] autodiff
    @ ~/Dropbox/Julia/Enzyme/src/Enzyme.jl:537 [inlined]
 [15] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{…}}, ::Duplicated{Vector{…}})
    @ Enzyme ~/Dropbox/Julia/Enzyme/src/Enzyme.jl:504
 [16] top-level scope
    @ REPL[9]:1
Some type information was truncated. Use `show(err)` to see complete types.
MasonProtter commented 1 month ago

v1.10:

julia> Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0))
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield90 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %281 unordered, align 8, !dbg !433, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !240, !align !241
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %getfield18 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %53 unordered, align 8, !dbg !291, !tbaa !211, !alias.scope !215, !noalias !218, !nonnull !0, !dereferenceable !261, !align !262
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %48 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %47, align 8, !dbg !212, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
┌ Warning: TODO reverse jl_array_del_end zero-set used memset rather than runtime type of (false, nothing) in   %61 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %60, align 8, !dbg !285, !tbaa !216, !alias.scope !220, !noalias !223
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
ERROR: Type Array does not have a definite size.
Stacktrace:
  [1] sizeof(x::Type)
    @ Base ./essentials.jl:631
  [2] jl_array_del_end_rev(B::LLVM.IRBuilder, orig::LLVM.CallInst, gutils::Enzyme.Compiler.GradientUtils, tape::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/rules/llvmrules.jl:1522
  [3] jl_array_del_end_rev_cfunc(B::Ptr{…}, OrigCI::Ptr{…}, gutils::Ptr{…}, tape::Ptr{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/rules/llvmrules.jl:48
  [4] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constant_args::Vector{…}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDerivativeMode, runtimeActivity::Bool, width::Int64, additionalArg::Ptr{…}, forceAnonymousTape::Bool, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{…}, augmented::Ptr{…}, atomicAdd::Bool)
    @ Enzyme.API ~/.julia/packages/Enzyme/HXYPU/src/api.jl:253
  [5] enzyme!(job::GPUCompiler.CompilerJob{…}, mod::LLVM.Module, primalf::LLVM.Function, TT::Type, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, wrap::Bool, modifiedBetween::Tuple{…}, returnPrimal::Bool, expectedTapeType::Type, loweredArgs::Set{…}, boxedArgs::Set{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:5096
  [6] codegen(output::Symbol, job::GPUCompiler.CompilerJob{…}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:8189
  [7] codegen
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:7028 [inlined]
  [8] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297
  [9] _thunk
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9297 [inlined]
 [10] cached_compilation
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9338 [inlined]
 [11] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, ::Val{…}, ::Type{…}, ::Type{…}, tt::Type{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Val{…}, ::Type{…}, ::Val{…}, ::Val{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9470
 [12] #s2064#19667
    @ ~/.julia/packages/Enzyme/HXYPU/src/compiler.jl:9607 [inlined]
 [13] 
    @ Enzyme.Compiler ./none:0
 [14] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:602
 [15] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:473 [inlined]
 [16] autodiff
    @ ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:537 [inlined]
 [17] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{…}}, ::Duplicated{Vector{…}})
    @ Enzyme ~/.julia/packages/Enzyme/HXYPU/src/Enzyme.jl:504
 [18] top-level scope
    @ REPL[11]:1
Some type information was truncated. Use `show(err)` to see complete types.
wsmoses commented 1 month ago

1.11 isn't expected to work atm.

And that error log for 1.10 implies you aren't using the linked branch? Since that line where the error occurs was explicitly changed to call somethign different (and the error messages changed)

wsmoses commented 1 month ago

@MasonProtter running this myself, it seems fine tho errs with a non enzyme issue edit: staticarrays dep is hard in my dev environment


julia> Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0))

ERROR: UndefVarError: `_saveat` not defined
Stacktrace:
 [1] f
   @ ./REPL[6]:4 [inlined]
 [2] diffejulia_f_1396wrap
   @ ./REPL[6]:0
 [3] macro expansion
   @ ~/git/Enzyme.jl/src/compiler.jl:9227 [inlined]
 [4] enzyme_call
   @ ~/git/Enzyme.jl/src/compiler.jl:8793 [inlined]
 [5] CombinedAdjointThunk
   @ ~/git/Enzyme.jl/src/compiler.jl:8566 [inlined]
 [6] autodiff
   @ ~/git/Enzyme.jl/src/Enzyme.jl:491 [inlined]
 [7] autodiff
   @ ~/git/Enzyme.jl/src/Enzyme.jl:537 [inlined]
 [8] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{Float64}}, ::Duplicated{Vector{Float64}})
   @ Enzyme ~/git/Enzyme.jl/src/Enzyme.jl:504
 [9] top-level scope
   @ REPL[11]:1
wsmoses commented 1 month ago

Now hits


Caused by:
Stacktrace:
 [1] ODEIntegrator
   @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/type.jl:88
 [2] #__init#76
   @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:474
within MethodInstance for OrdinaryDiffEqCore.var"#__init#76"(::NTuple{13, Float64}, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Bool, ::Bool, ::Float64, ::Float64, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Nothing, ::Rational{Int64}, ::Nothing, ::Bool, ::Int64, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Symbol, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEqCore.DefaultInit, ::Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, ::typeof(SciMLBase.__init), ::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, SciMLBase.NullParameters, ODEFunction{true, SciMLBase.FullSpecialize, typeof(lorenz!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}, SciMLBase.StandardODEProblem}, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})

Stacktrace:
  [1] ODEIntegrator
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/type.jl:88 [inlined]
  [2] #__init#76
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:474
  [3] __init (repeats 5 times)
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:11 [inlined]
  [4] #__solve#75
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:6 [inlined]
  [5] __solve
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:1 [inlined]
  [6] #solve_call#44
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:612
  [7] solve_call
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:569 [inlined]
  [8] #solve_up#53
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:1084 [inlined]
  [9] solve_up
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:1070 [inlined]
 [10] #solve#51
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:1007 [inlined]
 [11] solve
    @ ~/.julia/packages/DiffEqBase/sIf7D/src/solve.jl:997 [inlined]
 [12] f
    @ ./REPL[14]:4 [inlined]
 [13] diffejulia_f_3094wrap
    @ ./REPL[14]:0
 [14] macro expansion
    @ ~/git/Enzyme.jl/src/compiler.jl:9227 [inlined]
 [15] enzyme_call
    @ ~/git/Enzyme.jl/src/compiler.jl:8793 [inlined]
 [16] CombinedAdjointThunk
    @ ~/git/Enzyme.jl/src/compiler.jl:8566 [inlined]
 [17] autodiff
    @ ~/git/Enzyme.jl/src/Enzyme.jl:491 [inlined]
 [18] autodiff
    @ ~/git/Enzyme.jl/src/Enzyme.jl:537 [inlined]
 [19] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{Float64}}, ::Duplicated{Vector{Float64}})
    @ Enzyme ~/git/Enzyme.jl/src/Enzyme.jl:504
 [20] top-level scope
    @ REPL[19]:1

which I presume setting a maxtypeoffset of like 1000 or loosetypeanalysis or something would resolve

wsmoses commented 1 month ago

With some more type info via https://github.com/EnzymeAD/Enzyme.jl/pull/1916 we now have

└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/2CW9L/src/utils.jl:59
ERROR: ReadOnlyMemoryError()
Stacktrace:
 [1] diffejulia_f_1197wrap
   @ ./REPL[3]:0
 [2] macro expansion
   @ ~/git/Enzyme.jl/src/compiler.jl:9229 [inlined]
 [3] enzyme_call
   @ ~/git/Enzyme.jl/src/compiler.jl:8795 [inlined]
 [4] CombinedAdjointThunk
   @ ~/git/Enzyme.jl/src/compiler.jl:8568 [inlined]
 [5] autodiff
   @ ~/git/Enzyme.jl/src/Enzyme.jl:491 [inlined]
 [6] autodiff
   @ ~/git/Enzyme.jl/src/Enzyme.jl:537 [inlined]
 [7] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{Float64}}, ::Duplicated{Vector{Float64}})
   @ Enzyme ~/git/Enzyme.jl/src/Enzyme.jl:504

@ChrisRackauckas and/or @MasonProtter would you be able to help minimize the source of this error. I'm a bit confused why it's coming up

wsmoses commented 1 month ago

this segfaults:

using Enzyme, OrdinaryDiffEqTsit5

function lorenz!(du, u, p, t)
    du[1] = 10.0(u[2] - u[1])
    du[2] = u[1] * (28.0 - u[3]) - u[2]
    du[3] = u[1] * u[2] - (8 / 3) * u[3]
end

function f(y::Array{Float64}, u0::Array{Float64})
    tspan = (0.0, 3.0)
    prob = ODEProblem{true, SciMLBase.FullSpecialize}(lorenz!, u0, tspan)
    sol = DiffEqBase.solve(prob, Tsit5())
    return nothing
end;
u0 = [1.0; 0.0; 0.0]
d_u0 = zeros(3)
y  = zeros(13)
dy = zeros(13)

Enzyme.autodiff(Reverse, f,  Duplicated(y, dy), Duplicated(u0, d_u0))
wsmoses commented 1 month ago

On main this now appears completely resolved, hitting the fastpow stuff @ChrisRackauckas was working on.

As I presume that he has a fix in other repos, am going to close.

cannot handle unknown binary operator:   %105 = and i32 %bitcast_coercion74, 8388607, !dbg !396

Stacktrace:
 [1] &
   @ ./int.jl:347
 [2] fastlog2
   @ ~/.julia/packages/DiffEqBase/vscDj/src/fastpow.jl:25
 [3] fastpow
   @ ~/.julia/packages/DiffEqBase/vscDj/src/fastpow.jl:66
 [4] stepsize_controller!
   @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/controllers.jl:145
 [5] stepsize_controller!
   @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/controllers.jl:5
 [6] _loopfooter!
   @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/integrator_utils.jl:226

Stacktrace:
  [1] &
    @ ./int.jl:347 [inlined]
  [2] fastlog2
    @ ~/.julia/packages/DiffEqBase/vscDj/src/fastpow.jl:25 [inlined]
  [3] fastpow
    @ ~/.julia/packages/DiffEqBase/vscDj/src/fastpow.jl:66 [inlined]
  [4] stepsize_controller!
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/controllers.jl:145 [inlined]
  [5] stepsize_controller!
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/controllers.jl:5 [inlined]
  [6] _loopfooter!
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/integrator_utils.jl:226
  [7] loopfooter!
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/integrators/integrator_utils.jl:207 [inlined]
  [8] solve!
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:552
  [9] #__solve#75
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:7 [inlined]
 [10] __solve
    @ ~/.julia/packages/OrdinaryDiffEqCore/55UVY/src/solve.jl:1 [inlined]
 [11] #solve_call#44
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:612 [inlined]
 [12] solve_call
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:569 [inlined]
 [13] #solve_up#53
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:1084 [inlined]
 [14] solve_up
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:1070 [inlined]
 [15] #solve#51
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:1007 [inlined]
 [16] solve
    @ ~/.julia/packages/DiffEqBase/vscDj/src/solve.jl:997 [inlined]
 [17] f
    @ ./REPL[6]:4 [inlined]
 [18] diffejulia_f_1333wrap
    @ ./REPL[6]:0
 [19] macro expansion
    @ ~/git/Enzyme.jl/src/compiler.jl:9229 [inlined]
 [20] enzyme_call
    @ ~/git/Enzyme.jl/src/compiler.jl:8795 [inlined]
 [21] CombinedAdjointThunk
    @ ~/git/Enzyme.jl/src/compiler.jl:8568 [inlined]
 [22] autodiff
    @ ~/git/Enzyme.jl/src/Enzyme.jl:491 [inlined]
 [23] autodiff
    @ ~/git/Enzyme.jl/src/Enzyme.jl:537 [inlined]
 [24] autodiff(::ReverseMode{false, false, FFIABI, false, false}, ::typeof(f), ::Duplicated{Vector{Float64}}, ::Duplicated{Vector{Float64}})
    @ Enzyme ~/git/Enzyme.jl/src/Enzyme.jl:504
 [25] top-level scope
    @ REPL[11]:1
MasonProtter commented 1 month ago

@wsmoses sorry, I messed up and forgot that [sources] doesn't work in 1.10, so my 1.10 test wasn't actually on your branch, my bad.