Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enzyme returns incorrect gradient when push! is used in Julia v1.11 #2209

Open
jonniediegelman opened this issue Dec 18, 2024 · 2 comments
Open

Comments

@jonniediegelman
Copy link

On Julia 1.11:

julia> using Enzyme

julia> autodiff(Forward, Duplicated(10.0, 1.0)) do x
           v = typeof(x)[]
           push!(v, x)
           v[1]
       end
(0.0,)

On Julia 1.10:

julia> using Enzyme

julia> autodiff(Forward, Duplicated(10.0, 1.0)) do x
           v = typeof(x)[]
           push!(v, x)
           v[1]
       end
(1.0,)
@jonniediegelman jonniediegelman changed the title Enzyme returns gradient when push! is used in Julia v1.11 Enzyme returns incorrect gradient when push! is used in Julia v1.11 Dec 18, 2024
@MasonProtter
Copy link

MasonProtter commented Dec 18, 2024

Just a note, this fails for both forward and reverse mode.

Here's some breadcrumbs to help figure out what went wrong. The above is incorrect on 1.11, but this is fine:

julia> autodiff(Forward, Duplicated(10.0, 1.0)) do x
           v = typeof(x)[1.0]
           push!(v, x)
           v[end]
       end
(1.0,)

So I think what's happening is that Enzyme is failing to realize that when you push! to an empty array, that array's Memory is going to be replaced with a new Memory, which makes it track the wrong thing? Not sure.

@MasonProtter
Copy link

Here's one more potential breadcrumb:

julia> autodiff(Forward, Duplicated(10.0, 1.0)) do x
           v = typeof(x)[]
           for i  1:10
               push!(v, 1.0)
           end
           push!(v, x)
           v[end]
       end
ERROR: Enzyme compilation failed due to an internal error.
 Please open an issue with the code to reproduce and full error log on github.com/EnzymeAD/Enzyme.jl
 To toggle more information for debugging (needed for bug reports), set Enzyme.Compiler.VERBOSE_ERRORS[] = true (default false)
Current scope: 
define "enzyme_type"="{[-1]:Float@double}" double @julia__37_18460(double returned "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="140604885255648" "enzymejl_parmtype_ref"="0" %0) local_unnamed_addr #12 !dbg !7 {
top:
  %1 = alloca [1 x {} addrspace(10)*], align 8
  %2 = alloca { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, align 8
  %3 = alloca [1 x {} addrspace(10)*], align 8
  %4 = alloca { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, align 8
  %5 = alloca [1 x i64], align 8
  %pgcstack = call {}*** @julia.get_pgcstack()
  %ptls_field51 = getelementptr inbounds {}**, {}*** %pgcstack, i64 2
  %6 = bitcast {}*** %ptls_field51 to i64***
  %ptls_load5253 = load i64**, i64*** %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i64*, i64** %ptls_load5253, i64 2
  %safepoint = load i64*, i64** %7, align 8, !tbaa !15
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint), !dbg !17
  fence syncscope("singlethread") seq_cst
  %8 = load atomic {} addrspace(10)*, {} addrspace(10)** inttoptr (i64 140604831150096 to {} addrspace(10)**) unordered, align 16, !dbg !18, !tbaa !26, !alias.scope !27, !noalias !31
  %.not = icmp eq {} addrspace(10)* %8, null, !dbg !18
  br i1 %.not, label %fail, label %pass, !dbg !18

L4:                                               ; preds = %L22, %pass
  %9 = phi {} addrspace(10)* [ %8, %pass ], [ %27, %L22 ]
  %10 = phi i8* [ %68, %pass ], [ %28, %L22 ]
  %11 = phi i64 [ 0, %pass ], [ %29, %L22 ], !dbg !35
  %value_phi = phi i64 [ 1, %pass ], [ %35, %L22 ]
  %12 = add i64 %11, 1, !dbg !43
  %13 = bitcast {} addrspace(10)* %9 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !47
  %14 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %13 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !47
  %15 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %14, i64 0, i32 1, !dbg !47
  %16 = bitcast {} addrspace(10)** addrspace(11)* %15 to {}* addrspace(11)*, !dbg !47
  %17 = load {}*, {}* addrspace(11)* %16, align 8, !dbg !47, !tbaa !15, !alias.scope !48, !noalias !49, !nonnull !10
  %18 = ptrtoint {}* %17 to i64, !dbg !47
  %19 = ptrtoint i8* %10 to i64, !dbg !47
  %20 = sub i64 %19, %18, !dbg !47
  %21 = lshr exact i64 %20, 3, !dbg !47
  %22 = add nuw nsw i64 %21, 1, !dbg !47
  store i64 %12, i64 addrspace(11)* %75, align 8, !dbg !50, !tbaa !51, !alias.scope !54, !noalias !55
  %23 = add i64 %22, %11, !dbg !58
  %24 = bitcast {} addrspace(10)* %9 to i64 addrspace(10)*, !dbg !61
  %25 = addrspacecast i64 addrspace(10)* %24 to i64 addrspace(11)*, !dbg !61
  %26 = load i64, i64 addrspace(11)* %25, align 8, !dbg !61, !tbaa !64, !alias.scope !54, !noalias !66
  %.not61 = icmp slt i64 %26, %23, !dbg !61
  br i1 %.not61, label %L19, label %L22, !dbg !63

L19:                                              ; preds = %L4
  store {} addrspace(10)* %69, {} addrspace(10)** %.fca.0.gep15, align 8, !dbg !67, !noalias !68
  store i64 %23, i64* %.fca.1.gep17, align 8, !dbg !67, !noalias !68
  store i64 %22, i64* %.fca.2.gep19, align 8, !dbg !67, !noalias !68
  store i64 %12, i64* %.fca.3.gep21, align 8, !dbg !67, !noalias !68
  store i64 %11, i64* %.fca.4.gep23, align 8, !dbg !67, !noalias !68
  store i64 %26, i64* %.fca.5.gep25, align 8, !dbg !67, !noalias !68
  store {} addrspace(10)* %9, {} addrspace(10)** %.fca.6.gep27, align 8, !dbg !67, !noalias !68
  store i8* %10, i8** %.fca.7.0.gep29, align 8, !dbg !67, !noalias !68
  store {} addrspace(10)* %9, {} addrspace(10)** %.fca.7.1.gep31, align 8, !dbg !67, !noalias !68
  call fastcc void @julia__133_18493([1 x {} addrspace(10)*]* noalias nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) "enzymejl_returnRoots" %1, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } } addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(72) %76), !dbg !67
  %.pre39 = load i64, i64 addrspace(11)* %75, align 8, !dbg !69, !tbaa !51, !alias.scope !54, !noalias !66
  %.pre40 = load i8*, i8* addrspace(11)* %.repack58, align 8, !dbg !71, !tbaa !76, !alias.scope !54, !noalias !66
  %.pre41 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %.repack59, align 8, !dbg !71, !tbaa !76, !alias.scope !54, !noalias !66
  br label %L22, !dbg !67

L22:                                              ; preds = %L4, %L19
  %27 = phi {} addrspace(10)* [ %9, %L4 ], [ %.pre41, %L19 ], !dbg !71
  %28 = phi i8* [ %10, %L4 ], [ %.pre40, %L19 ], !dbg !71
  %29 = phi i64 [ %12, %L4 ], [ %.pre39, %L19 ], !dbg !69
  %30 = add i64 %29, -1, !dbg !74
  %31 = bitcast i8* %28 to {} addrspace(10)**, !dbg !74
  %32 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* noundef %27, {} addrspace(10)** noundef %31), !dbg !74
  %33 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %32, i64 %30, !dbg !74
  %34 = bitcast {} addrspace(10)* addrspace(13)* %33 to double addrspace(13)*, !dbg !74
  store double 1.000000e+00, double addrspace(13)* %34, align 8, !dbg !74, !tbaa !78, !alias.scope !81, !noalias !82
  %.not62 = icmp eq i64 %value_phi, 10, !dbg !83
  %35 = add nuw nsw i64 %value_phi, 1
  br i1 %.not62, label %L39, label %L4, !dbg !89

L39:                                              ; preds = %L22
  %36 = add i64 %29, 1, !dbg !90
  %37 = bitcast {} addrspace(10)* %27 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !94
  %38 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %37 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !94
  %39 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %38, i64 0, i32 1, !dbg !94
  %40 = bitcast {} addrspace(10)** addrspace(11)* %39 to {}* addrspace(11)*, !dbg !94
  %41 = load {}*, {}* addrspace(11)* %40, align 8, !dbg !94, !tbaa !15, !alias.scope !48, !noalias !49, !nonnull !10
  %42 = ptrtoint {}* %41 to i64, !dbg !94
  %43 = ptrtoint i8* %28 to i64, !dbg !94
  %44 = sub i64 %43, %42, !dbg !94
  %45 = lshr exact i64 %44, 3, !dbg !94
  %46 = add nuw nsw i64 %45, 1, !dbg !94
  store i64 %36, i64 addrspace(11)* %75, align 8, !dbg !95, !tbaa !51, !alias.scope !54, !noalias !55
  %47 = add i64 %46, %29, !dbg !96
  %48 = bitcast {} addrspace(10)* %27 to i64 addrspace(10)*, !dbg !98
  %49 = addrspacecast i64 addrspace(10)* %48 to i64 addrspace(11)*, !dbg !98
  %50 = load i64, i64 addrspace(11)* %49, align 8, !dbg !98, !tbaa !64, !alias.scope !54, !noalias !66
  %.not63 = icmp slt i64 %50, %47, !dbg !98
  br i1 %.not63, label %L53, label %L56, !dbg !99

L53:                                              ; preds = %L39
  %.fca.0.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 0, !dbg !100
  store {} addrspace(10)* %69, {} addrspace(10)** %.fca.0.gep, align 8, !dbg !100, !noalias !68
  %.fca.1.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 1, !dbg !100
  store i64 %47, i64* %.fca.1.gep, align 8, !dbg !100, !noalias !68
  %.fca.2.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 2, !dbg !100
  store i64 %46, i64* %.fca.2.gep, align 8, !dbg !100, !noalias !68
  %.fca.3.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 3, !dbg !100
  store i64 %36, i64* %.fca.3.gep, align 8, !dbg !100, !noalias !68
  %.fca.4.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 4, !dbg !100
  store i64 %29, i64* %.fca.4.gep, align 8, !dbg !100, !noalias !68
  %.fca.5.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 5, !dbg !100
  store i64 %50, i64* %.fca.5.gep, align 8, !dbg !100, !noalias !68
  %.fca.6.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 6, !dbg !100
  store {} addrspace(10)* %27, {} addrspace(10)** %.fca.6.gep, align 8, !dbg !100, !noalias !68
  %.fca.7.0.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 7, i32 0, !dbg !100
  store i8* %28, i8** %.fca.7.0.gep, align 8, !dbg !100, !noalias !68
  %.fca.7.1.gep = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4, i64 0, i32 7, i32 1, !dbg !100
  store {} addrspace(10)* %27, {} addrspace(10)** %.fca.7.1.gep, align 8, !dbg !100, !noalias !68
  %51 = addrspacecast { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %4 to { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } } addrspace(11)*, !dbg !100
  call fastcc void @julia__133_18493([1 x {} addrspace(10)*]* noalias nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) "enzymejl_returnRoots" %3, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } } addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(72) %51), !dbg !100
  %.pre42 = load i64, i64 addrspace(11)* %75, align 8, !dbg !101, !tbaa !51, !alias.scope !54, !noalias !66
  %52 = bitcast {} addrspace(10)* %69 to {} addrspace(10)** addrspace(10)*, !dbg !103
  %53 = addrspacecast {} addrspace(10)** addrspace(10)* %52 to {} addrspace(10)** addrspace(11)*, !dbg !103
  %.pre4364 = load {} addrspace(10)**, {} addrspace(10)** addrspace(11)* %53, align 8, !dbg !103, !tbaa !76, !alias.scope !54, !noalias !66
  %.pre44 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %.repack59, align 8, !dbg !103, !tbaa !76, !alias.scope !54, !noalias !66
  %.pre46 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* noundef %.pre44, {} addrspace(10)** noundef %.pre4364), !dbg !104
  br label %L56, !dbg !100

L56:                                              ; preds = %L39, %L53
  %nodecayed..pre-phi49.in = phi {} addrspace(10)* 
  %nodecayedoff..pre-phi49.in = phi i64 
  %.pre-phi49.in = phi {} addrspace(10)* addrspace(13)* [ %32, %L39 ], [ %.pre46, %L53 ]
  %54 = phi i64 [ %36, %L39 ], [ %.pre42, %L53 ], !dbg !105
  %55 = add i64 %54, -1, !dbg !104
  %56 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %.pre-phi49.in, i64 %55, !dbg !104
  %57 = bitcast {} addrspace(10)* addrspace(13)* %56 to double addrspace(13)*, !dbg !104
  store double %0, double addrspace(13)* %57, align 8, !dbg !104, !tbaa !78, !alias.scope !81, !noalias !82
  %.not65 = icmp eq i64 %54, 0, !dbg !106
  br i1 %.not65, label %L77, label %L80, !dbg !106

L77:                                              ; preds = %L56
  %58 = getelementptr inbounds [1 x i64], [1 x i64]* %5, i64 0, i64 0, !dbg !106
  store i64 0, i64* %58, align 8, !dbg !106, !tbaa !109, !alias.scope !111, !noalias !112
  %59 = addrspacecast [1 x i64]* %5 to [1 x i64] addrspace(11)*, !dbg !106
  call fastcc void @julia_throw_boundserror_18486({} addrspace(10)* nofree noundef nonnull align 8 dereferenceable(24) %69, [1 x i64] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) %59) #18, !dbg !106
  unreachable, !dbg !106

L80:                                              ; preds = %L56
  ret double %0, !dbg !113

fail:                                             ; preds = %top
  %60 = load {}*, {}** @jl_undefref_exception, align 8, !dbg !18, !tbaa !15, !alias.scope !48, !noalias !49, !nonnull !10
  %61 = addrspacecast {}* %60 to {} addrspace(12)*, !dbg !18
  call void @ijl_throw({} addrspace(12)* %61) #18, !dbg !18
  unreachable, !dbg !18

pass:                                             ; preds = %top
  %current_task150 = getelementptr inbounds {}**, {}*** %pgcstack, i64 -14
  %62 = bitcast {}*** %current_task150 to {}*
  %ptls_load.i5455 = load i64**, i64*** %6, align 8, !tbaa !11, !noalias !114
  %63 = getelementptr inbounds i64*, i64** %ptls_load.i5455, i64 2
  %safepoint.i = load i64*, i64** %63, align 8, !tbaa !15, !noalias !114
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint.i), !dbg !118, !noalias !114
  fence syncscope("singlethread") seq_cst
  %64 = bitcast {} addrspace(10)* %8 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !118
  %65 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %64 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !118
  %66 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %65, i64 0, i32 1, !dbg !118
  %67 = bitcast {} addrspace(10)** addrspace(11)* %66 to i8* addrspace(11)*, !dbg !118
  %68 = load i8*, i8* addrspace(11)* %67, align 8, !dbg !118, !tbaa !26, !alias.scope !27, !noalias !31, !nonnull !10
  %69 = call noalias nonnull align 8 dereferenceable(24) {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %62, i64 noundef 24, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140604831460176 to {}*) to {} addrspace(10)*)) #19, !dbg !121
  %70 = bitcast {} addrspace(10)* %69 to { i8*, {} addrspace(10)* } addrspace(10)*, !dbg !121
  %71 = addrspacecast { i8*, {} addrspace(10)* } addrspace(10)* %70 to { i8*, {} addrspace(10)* } addrspace(11)*, !dbg !121
  %.repack58 = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %71, i64 0, i32 0, !dbg !121
  store i8* %68, i8* addrspace(11)* %.repack58, align 8, !dbg !121, !tbaa !76, !alias.scope !54, !noalias !55
  %.repack59 = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %71, i64 0, i32 1, !dbg !121
  store {} addrspace(10)* %8, {} addrspace(10)* addrspace(11)* %.repack59, align 8, !dbg !121, !tbaa !76, !alias.scope !54, !noalias !55
  %72 = bitcast {} addrspace(10)* %69 to i8 addrspace(10)*, !dbg !121
  %73 = addrspacecast i8 addrspace(10)* %72 to i8 addrspace(11)*, !dbg !121
  %74 = getelementptr inbounds i8, i8 addrspace(11)* %73, i64 16, !dbg !121
  %75 = bitcast i8 addrspace(11)* %74 to i64 addrspace(11)*, !dbg !121
  store i64 0, i64 addrspace(11)* %75, align 8, !dbg !121, !tbaa !51, !alias.scope !54, !noalias !55
  %.fca.0.gep15 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 0
  %.fca.1.gep17 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 1
  %.fca.2.gep19 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 2
  %.fca.3.gep21 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 3
  %.fca.4.gep23 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 4
  %.fca.5.gep25 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 5
  %.fca.6.gep27 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 6
  %.fca.7.0.gep29 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 7, i32 0
  %.fca.7.1.gep31 = getelementptr inbounds { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }, { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2, i64 0, i32 7, i32 1
  %76 = addrspacecast { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } }* %2 to { {} addrspace(10)*, i64, i64, i64, i64, i64, {} addrspace(10)*, { i8*, {} addrspace(10)* } } addrspace(11)*
  br label %L4, !dbg !121
}

Could not analyze garbage collection behavior of
 inst:   %.pre-phi49.in = phi {} addrspace(10)* addrspace(13)* [ %32, %L39 ], [ %.pre46, %L53 ]
 v0:   %32 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* noundef %27, {} addrspace(10)** noundef %31), !dbg !74
 v:   %32 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* noundef %27, {} addrspace(10)** noundef %31), !dbg !74
 offset: i64 0
 hasload: false



Stacktrace:
  [1] (::Enzyme.Compiler.var"#getparent#69"{})(v::LLVM.Value, offset::LLVM.Value, hasload::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/llvm/transforms.jl:888
  [2] nodecayed_phis!(mod::LLVM.Module)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/llvm/transforms.jl:891
  [3] optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/compiler/optimize.jl:582
  [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/ydGh2/src/compiler.jl:4107
  [5] codegen
    @ ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:3239 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:5288
  [7] _thunk
    @ ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:5288 [inlined]
  [8] cached_compilation
    @ ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:5340 [inlined]
  [9] thunkbase(mi::Core.MethodInstance, World::UInt64, FA::Type{…}, A::Type{…}, TT::Type, Mode::Enzyme.API.CDerivativeMode, width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, edges::Vector{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:5451
 [10] thunk_generator(world::UInt64, source::LineNumberNode, FA::Type, A::Type, TT::Type, Mode::Enzyme.API.CDerivativeMode, Width::Int64, ModifiedBetween::NTuple{…} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, self::Any, fakeworld::Any, fa::Type, a::Type, tt::Type, mode::Type, width::Type, modifiedbetween::Type, returnprimal::Type, shadowinit::Type, abi::Type, erriffuncwritten::Type, runtimeactivity::Type)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/ydGh2/src/compiler.jl:5636
 [11] autodiff
    @ ~/.julia/packages/Enzyme/ydGh2/src/Enzyme.jl:640 [inlined]
 [12] autodiff(mode::ForwardMode{false, FFIABI, true, false}, f::Const{var"#37#38"}, args::Duplicated{Float64})
    @ Enzyme ~/.julia/packages/Enzyme/ydGh2/src/Enzyme.jl:544
 [13] autodiff
    @ ~/.julia/packages/Enzyme/ydGh2/src/Enzyme.jl:516 [inlined]
 [14] autodiff(f::Function, m::ForwardMode{false, FFIABI, false, false}, args::Duplicated{Float64})
    @ Enzyme ~/.julia/packages/Enzyme/ydGh2/src/Enzyme.jl:1019
 [15] top-level scope
    @ REPL[30]:1
Some type information was truncated. Use `show(err)` to see complete types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants