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

Cholesky solve segfault #1649

Closed
mhauru opened this issue Jul 17, 2024 · 5 comments
Closed

Cholesky solve segfault #1649

mhauru opened this issue Jul 17, 2024 · 5 comments

Comments

@mhauru
Copy link
Contributor

mhauru commented Jul 17, 2024

module MWE

import Enzyme
import LinearAlgebra
import Base: size

struct Wishart{T, ST, R}
    df::T
    S::ST
    rank::R
    singular::Bool
end

function Wishart(df, S)
    p = size(S, 1)
    singular = df <= p - 1
    rnk::Integer = ifelse(singular, df, p)
    _df = promote(df)
    Wishart{typeof(_df), typeof(S), typeof(rnk)}(_df, S, rnk, singular)
end

Wishart(df::Real, S::Matrix) = Wishart(df, LinearAlgebra.cholesky(S))

Base.size(d::Wishart, idx) = size(d.S, idx)

function nonsingular_wishart_logkernel(d, X)
    return LinearAlgebra.tr(d.S \ X)
end

function f(x)
    mat = Matrix{Float64}(undef, 2, 2)
    mat[1, 1] = 1.0
    mat[1, 2] = 0.5
    mat[2, 1] = 0.5
    mat[2, 2] = 1.0
    d = Wishart(7.0, mat)
    return nonsingular_wishart_logkernel(d, x)
end

x = Matrix{Float64}(undef, 2, 2)
x[1, 1] = 0.07794158346991019
x[1, 2] = -0.14797673272687734
x[2, 1] = -0.14797673272687734
x[2, 2] = 4.1478979139888015
Enzyme.gradient(Enzyme.Reverse, f, x)

end

Output:

[55301] signal (11.2): Segmentation fault: 11
in expression starting at /Users/mhauru/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:47
unsafe_convert at ./pointer.jl:65 [inlined]
potrs! at /Users/mhauru/projects/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/lapack.jl:3276
ldiv! at /Users/mhauru/projects/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/cholesky.jl:577 [inlined]
ldiv at /Users/mhauru/projects/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/LinearAlgebra.jl:572
\ at /Users/mhauru/projects/julia/usr/share/julia/stdlib/v1.10/LinearAlgebra/src/LinearAlgebra.jl:547 [inlined]
nonsingular_wishart_logkernel at /Users/mhauru/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:29
f at /Users/mhauru/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:39 [inlined]
diffejulia_f_1554wrap at /Users/mhauru/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:0
macro expansion at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6630 [inlined]
enzyme_call at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6231 [inlined]
CombinedAdjointThunk at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/compiler.jl:6108 [inlined]
autodiff at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/Enzyme.jl:314 [inlined]
autodiff at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/Enzyme.jl:326 [inlined]
gradient at /Users/mhauru/.julia/packages/Enzyme/Pljwm/src/Enzyme.jl:1027
_jl_invoke at /Users/mhauru/projects/julia/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/mhauru/projects/julia/src/gf.c:3077
jl_apply at /Users/mhauru/projects/julia/src/./julia.h:1982 [inlined]
do_call at /Users/mhauru/projects/julia/src/interpreter.c:126
eval_body at /Users/mhauru/projects/julia/src/interpreter.c:0
jl_interpret_toplevel_thunk at /Users/mhauru/projects/julia/src/interpreter.c:775
jl_toplevel_eval_flex at /Users/mhauru/projects/julia/src/toplevel.c:934
jl_eval_module_expr at /Users/mhauru/projects/julia/src/toplevel.c:215 [inlined]
jl_toplevel_eval_flex at /Users/mhauru/projects/julia/src/toplevel.c:736
jl_toplevel_eval_flex at /Users/mhauru/projects/julia/src/toplevel.c:877
ijl_toplevel_eval at /Users/mhauru/projects/julia/src/toplevel.c:943 [inlined]
ijl_toplevel_eval_in at /Users/mhauru/projects/julia/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
_jl_invoke at /Users/mhauru/projects/julia/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/mhauru/projects/julia/src/gf.c:3077
_include at ./loading.jl:2136
include at ./Base.jl:495
jfptr_include_46582 at /Users/mhauru/projects/julia/usr/lib/julia/sys.dylib (unknown line)
_jl_invoke at /Users/mhauru/projects/julia/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/mhauru/projects/julia/src/gf.c:3077
exec_options at ./client.jl:318
_start at ./client.jl:552
jfptr__start_82924 at /Users/mhauru/projects/julia/usr/lib/julia/sys.dylib (unknown line)
_jl_invoke at /Users/mhauru/projects/julia/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/mhauru/projects/julia/src/gf.c:3077
jl_apply at /Users/mhauru/projects/julia/src/./julia.h:1982 [inlined]
true_main at /Users/mhauru/projects/julia/src/jlapi.c:582
jl_repl_entrypoint at /Users/mhauru/projects/julia/src/jlapi.c:731
Allocations: 36027975 (Pool: 35978421; Big: 49554); GC: 44
Segmentation fault: 11

Enzyme v0.12.23

@wsmoses
Copy link
Member

wsmoses commented Jul 21, 2024

Should be fixed by #1657 please reopen otherwise

@wsmoses wsmoses closed this as completed Jul 21, 2024
@yebai
Copy link

yebai commented Jul 21, 2024

@wsmoses, should a test be added when closing issues? In addition, I don’t see any cross reference when fixing problems. It’s hard to see which PR fixed which issue…

@wsmoses
Copy link
Member

wsmoses commented Jul 21, 2024

A test was added, see here: EnzymeAD/Enzyme#1995

@yebai
Copy link

yebai commented Jul 22, 2024

Does it make sense to include the MWE as a test on the Julia side? That would prevent future Enzyme changes from breaking the same Julia code again.

@mhauru
Copy link
Contributor Author

mhauru commented Sep 18, 2024

Works on 1.10.5 but crashes on 1.7 with

[ Info: Precompiling Enzyme [7da242da-08ed-463a-9acd-ee780be4f1d9]
ERROR: LoadError: Enzyme compilation failed due to illegal type analysis.
Current scope:
; Function Attrs: willreturn mustprogress
define "enzyme_type"="{[-1]:Float@double}" double @preprocess_julia_f_5874({} addrspace(10)* nonnull align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="13116723440" "enzymejl_parmtype_ref"="2" %0) local_unnamed_addr #49 !dbg !1264 {
top:
  %1 = alloca { {} addrspace(10)*, i32, i64 }, align 8
  %2 = alloca [1 x {} addrspace(10)*], align 8
  %3 = alloca i64, align 8
  %4 = alloca { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, align 8
  %5 = call {}*** @julia.get_pgcstack() #50
  %6 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @jl_alloc_array_2d({} addrspace(10)* addrspacecast ({}* inttoptr (i64 13116723440 to {}*) to {} addrspace(10)*), i64 2, i64 2) #51, !dbg !1265
  %7 = bitcast {} addrspace(10)* %6 to {} addrspace(10)* addrspace(10)*, !dbg !1267
  %8 = addrspacecast {} addrspace(10)* addrspace(10)* %7 to {} addrspace(10)* addrspace(11)*, !dbg !1267
  %9 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 3, !dbg !1267
  %10 = bitcast {} addrspace(10)* addrspace(11)* %9 to i64 addrspace(11)*, !dbg !1267
  %11 = load i64, i64 addrspace(11)* %10, align 8, !dbg !1267, !tbaa !63, !range !67
  %.not = icmp eq i64 %11, 0, !dbg !1267
  br i1 %.not, label %oob, label %ib, !dbg !1267

L23:                                              ; preds = %idxend6
  %12 = load double, double addrspace(11)* %67, align 8, !dbg !1269, !tbaa !124
  %13 = fcmp ult double %12, 0xC3E0000000000000, !dbg !1269
  %14 = fcmp uge double %12, 0x43E0000000000000, !dbg !1270
  %value_phi.off0 = or i1 %13, %14, !dbg !1270
  %15 = call double @llvm.trunc.f64(double %12) #50
  %16 = fcmp une double %15, %12
  %or.cond = or i1 %value_phi.off0, %16, !dbg !1270
  br i1 %or.cond, label %L36, label %L34, !dbg !1270

L34:                                              ; preds = %L23
  %17 = fptosi double %12 to i64, !dbg !1276
  %18 = freeze i64 %17, !dbg !1276
  br label %L48, !dbg !1273

L36:                                              ; preds = %L23
  %ptls_field19 = getelementptr inbounds {}**, {}*** %5, i64 2305843009213693954, !dbg !1278
  %19 = bitcast {}*** %ptls_field19 to i8**, !dbg !1278
  %ptls_load2021 = load i8*, i8** %19, align 8, !dbg !1278, !tbaa !122
  %20 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_load2021, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4694585776 to {}*) to {} addrspace(10)*)) #52, !dbg !1278
  %21 = bitcast {} addrspace(10)* %20 to double addrspace(10)*, !dbg !1278
  store double %12, double addrspace(10)* %21, align 8, !dbg !1278, !tbaa !293, !noalias !1279
  %22 = call cc38 nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* bitcast ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32, {} addrspace(10)*)* @jl_invoke to {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*)*)({} addrspace(10)* addrspacecast ({}* inttoptr (i64 13142459984 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4747176656 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4339842360 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4693385024 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %20) #50, !dbg !1278
  %23 = addrspacecast {} addrspace(10)* %22 to {} addrspace(12)*, !dbg !1278
  call void @jl_throw({} addrspace(12)* %23) #50, !dbg !1278
  unreachable, !dbg !1278

L44:                                              ; preds = %idxend6
  %24 = bitcast double addrspace(11)* %67 to i64 addrspace(11)*
  %25 = load i64, i64 addrspace(11)* %24, align 8, !tbaa !124
  br label %L48, !dbg !1273

L48:                                              ; preds = %L44, %L34
  %value_phi10 = phi i64 [ %18, %L34 ], [ %25, %L44 ]
  %26 = zext i1 %66 to i8, !dbg !1273
  %.fca.1.gep = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 1, !dbg !1282
  %.fca.1.load = load i32, i32* %.fca.1.gep, align 8, !dbg !1282
  %.fca.2.gep14 = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 2, !dbg !1282
  %.fca.2.load = load i64, i64* %.fca.2.gep14, align 8, !dbg !1282
  %.fca.0.0.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 0, i64 0, !dbg !1284
  store double 7.000000e+00, double* %.fca.0.0.gep, align 8, !dbg !1284, !noalias !1279
  %.fca.1.0.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 0, !dbg !1284
  store {} addrspace(10)* %50, {} addrspace(10)** %.fca.1.0.gep, align 8, !dbg !1284, !noalias !1279
  %.fca.1.1.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 1, !dbg !1284
  store i32 %.fca.1.load, i32* %.fca.1.1.gep, align 8, !dbg !1284, !noalias !1279
  %.fca.1.2.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 2, !dbg !1284
  store i64 %.fca.2.load, i64* %.fca.1.2.gep, align 8, !dbg !1284, !noalias !1279
  %.fca.2.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 2, !dbg !1284
  store i64 %value_phi10, i64* %.fca.2.gep, align 8, !dbg !1284, !noalias !1279
  %.fca.3.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 3, !dbg !1284
  store i8 %26, i8* %.fca.3.gep, align 8, !dbg !1284, !noalias !1279
  %27 = addrspacecast { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4 to { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 } addrspace(11)*, !dbg !1284
  %28 = call fastcc double @julia_nonsingular_wishart_logkernel_5878({ [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 } addrspace(11)* nocapture readonly %27, {} addrspace(10)* %0) #53, !dbg !1284
  ret double %28, !dbg !1284

ib:                                               ; preds = %top
  %29 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 4, !dbg !1267
  %30 = bitcast {} addrspace(10)* addrspace(11)* %29 to i64 addrspace(11)*, !dbg !1267
  %31 = load i64, i64 addrspace(11)* %30, align 8, !dbg !1267, !tbaa !63, !range !67
  %.not15 = icmp eq i64 %31, 0, !dbg !1267
  br i1 %.not15, label %oob, label %idxend, !dbg !1267

oob:                                              ; preds = %ib, %top
  %32 = alloca [2 x i64], align 8, !dbg !1267
  %.sub = getelementptr inbounds [2 x i64], [2 x i64]* %32, i64 0, i64 0
  store i64 1, i64* %.sub, align 8, !dbg !1267, !noalias !1279
  %33 = getelementptr inbounds [2 x i64], [2 x i64]* %32, i64 0, i64 1, !dbg !1267
  store i64 1, i64* %33, align 8, !dbg !1267, !noalias !1279
  %34 = addrspacecast {} addrspace(10)* %6 to {} addrspace(12)*, !dbg !1267
  call void @jl_bounds_error_ints({} addrspace(12)* %34, i64* nonnull %.sub, i64 2) #50, !dbg !1267
  unreachable, !dbg !1267

idxend:                                           ; preds = %ib
  %35 = bitcast {} addrspace(10)* %6 to double addrspace(13)* addrspace(10)*, !dbg !1267
  %36 = addrspacecast double addrspace(13)* addrspace(10)* %35 to double addrspace(13)* addrspace(11)*, !dbg !1267
  %37 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %36, align 8, !dbg !1267, !tbaa !63, !alias.scope !1279, !nonnull !4
  store double 1.000000e+00, double addrspace(13)* %37, align 8, !dbg !1267, !tbaa !177, !noalias !1279
  %.not24 = icmp eq i64 %31, 1, !dbg !1285
  br i1 %.not24, label %oob2, label %idxend3, !dbg !1285

oob2:                                             ; preds = %idxend
  %38 = alloca [2 x i64], align 8, !dbg !1285
  %.sub16 = getelementptr inbounds [2 x i64], [2 x i64]* %38, i64 0, i64 0
  store i64 1, i64* %.sub16, align 8, !dbg !1285, !noalias !1279
  %39 = getelementptr inbounds [2 x i64], [2 x i64]* %38, i64 0, i64 1, !dbg !1285
  store i64 2, i64* %39, align 8, !dbg !1285, !noalias !1279
  %40 = addrspacecast {} addrspace(10)* %6 to {} addrspace(12)*, !dbg !1285
  call void @jl_bounds_error_ints({} addrspace(12)* %40, i64* nonnull %.sub16, i64 2) #50, !dbg !1285
  unreachable, !dbg !1285

idxend3:                                          ; preds = %idxend
  %41 = getelementptr inbounds double, double addrspace(13)* %37, i64 %11, !dbg !1285
  store double 5.000000e-01, double addrspace(13)* %41, align 8, !dbg !1285, !tbaa !177, !noalias !1279
  %42 = icmp ugt i64 %11, 1, !dbg !1287
  br i1 %42, label %idxend6, label %oob5, !dbg !1287

oob5:                                             ; preds = %idxend3
  %43 = alloca [2 x i64], align 8, !dbg !1287
  %.sub17 = getelementptr inbounds [2 x i64], [2 x i64]* %43, i64 0, i64 0
  store i64 2, i64* %.sub17, align 8, !dbg !1287, !noalias !1279
  %44 = getelementptr inbounds [2 x i64], [2 x i64]* %43, i64 0, i64 1, !dbg !1287
  store i64 1, i64* %44, align 8, !dbg !1287, !noalias !1279
  %45 = addrspacecast {} addrspace(10)* %6 to {} addrspace(12)*, !dbg !1287
  call void @jl_bounds_error_ints({} addrspace(12)* %45, i64* nonnull %.sub17, i64 2) #50, !dbg !1287
  unreachable, !dbg !1287

idxend6:                                          ; preds = %idxend3
  %46 = getelementptr inbounds double, double addrspace(13)* %37, i64 1, !dbg !1287
  store double 5.000000e-01, double addrspace(13)* %46, align 8, !dbg !1287, !tbaa !177, !noalias !1279
  %47 = add nuw nsw i64 %11, 1, !dbg !1289
  %48 = getelementptr inbounds double, double addrspace(13)* %37, i64 %47, !dbg !1289
  store double 1.000000e+00, double addrspace(13)* %48, align 8, !dbg !1289, !tbaa !177, !noalias !1279
  call fastcc void @julia_cholesky_5957({ {} addrspace(10)*, i32, i64 }* noalias nocapture nonnull sret({ {} addrspace(10)*, i32, i64 }) %1, [1 x {} addrspace(10)*]* noalias nocapture nonnull "enzymejl_returnRoots" %2, {} addrspace(10)* %6) #53, !dbg !1274
  %49 = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 0, !dbg !1291
  %50 = load atomic {} addrspace(10)*, {} addrspace(10)** %49 unordered, align 8, !dbg !1291, !tbaa !205, !nonnull !4, !dereferenceable !282, !align !283
  %51 = bitcast {} addrspace(10)* %50 to {} addrspace(10)* addrspace(10)*, !dbg !1294
  %52 = addrspacecast {} addrspace(10)* addrspace(10)* %51 to {} addrspace(10)* addrspace(11)*, !dbg !1294
  %53 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %52, i64 3, !dbg !1294
  %54 = bitcast {} addrspace(10)* addrspace(11)* %53 to i64 addrspace(11)*, !dbg !1294
  %55 = load i64, i64 addrspace(11)* %54, align 8, !dbg !1294, !tbaa !63, !range !67
  %56 = add nsw i64 %55, -1, !dbg !1295
  %57 = sitofp i64 %56 to double, !dbg !1297
  %58 = icmp ugt i64 %55, 8, !dbg !1299
  %59 = icmp eq i64 %56, 7, !dbg !1301
  %60 = fcmp olt double %57, 0x43E0000000000000, !dbg !1299
  %61 = and i1 %59, %60, !dbg !1302
  %62 = fptosi double %57 to i64, !dbg !1303
  %63 = freeze i64 %62, !dbg !1303
  %64 = icmp slt i64 %63, %55, !dbg !1304
  %65 = and i1 %61, %64, !dbg !1302
  %66 = or i1 %58, %65, !dbg !1305
  store i64 %55, i64* %3, align 8, !dbg !1273, !noalias !1279
  %.0.sroa_cast1 = addrspacecast i64* %3 to double addrspace(11)*, !dbg !1273
  %67 = select i1 %66, double addrspace(11)* addrspacecast (double* @_j_const1 to double addrspace(11)*), double addrspace(11)* %.0.sroa_cast1, !dbg !1273
  br i1 %66, label %L23, label %L44, !dbg !1273
}

 Type analysis state:
<analysis>
  %22 = call cc38 nonnull "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* bitcast ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32, {} addrspace(10)*)* @jl_invoke to {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*)*)({} addrspace(10)* addrspacecast ({}* inttoptr (i64 13142459984 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4747176656 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4339842360 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4693385024 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %20) #50, !dbg !88: {[-1]:Pointer}, intvals: {}
  %49 = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 0, !dbg !109: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Pointer, [-1,0,0,-1]:Float@double, [-1,0,8]:Integer, [-1,0,9]:Integer, [-1,0,10]:Integer, [-1,0,11]:Integer, [-1,0,12]:Integer, [-1,0,13]:Integer, [-1,0,14]:Integer, [-1,0,15]:Integer, [-1,0,16]:Integer, [-1,0,17]:Integer, [-1,0,18]:Integer, [-1,0,19]:Integer, [-1,0,20]:Integer, [-1,0,21]:Integer, [-1,0,22]:Integer, [-1,0,23]:Integer, [-1,0,24]:Integer, [-1,0,25]:Integer, [-1,0,26]:Integer, [-1,0,27]:Integer, [-1,0,28]:Integer, [-1,0,29]:Integer, [-1,0,30]:Integer, [-1,0,31]:Integer, [-1,0,32]:Integer, [-1,0,33]:Integer, [-1,0,34]:Integer, [-1,0,35]:Integer, [-1,0,36]:Integer, [-1,0,37]:Integer, [-1,0,38]:Integer, [-1,0,39]:Integer}, intvals: {}
  %.fca.3.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 3, !dbg !100: {[-1]:Pointer, [-1,0]:Integer}, intvals: {}
  %.fca.2.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 2, !dbg !100: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %28 = call fastcc double @julia_nonsingular_wishart_logkernel_5878({ [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 } addrspace(11)* nocapture readonly %27, {} addrspace(10)* %0) #53, !dbg !100: {[-1]:Float@double}, intvals: {}
  %.fca.1.gep = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 1, !dbg !98: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}, intvals: {}
  %.fca.2.gep14 = getelementptr inbounds { {} addrspace(10)*, i32, i64 }, { {} addrspace(10)*, i32, i64 }* %1, i64 0, i32 2, !dbg !98: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %67 = select i1 %66, double addrspace(11)* addrspacecast (double* @_j_const1 to double addrspace(11)*), double addrspace(11)* %.0.sroa_cast1, !dbg !80: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
  %53 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %52, i64 3, !dbg !118: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}, intvals: {}
  %48 = getelementptr inbounds double, double addrspace(13)* %37, i64 %47, !dbg !107: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %9 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 3, !dbg !62: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}, intvals: {}
  %15 = call double @llvm.trunc.f64(double %12) #50: {[-1]:Float@double}, intvals: {}
  %29 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 4, !dbg !62: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %41 = getelementptr inbounds double, double addrspace(13)* %37, i64 %11, !dbg !103: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %46 = getelementptr inbounds double, double addrspace(13)* %37, i64 1, !dbg !105: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %.fca.0.0.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 0, i64 0, !dbg !100: {[-1]:Pointer, [-1,0]:Float@double}, intvals: {}
  %.fca.1.2.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 2, !dbg !100: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %6 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @jl_alloc_array_2d({} addrspace(10)* addrspacecast ({}* inttoptr (i64 13116723440 to {}*) to {} addrspace(10)*), i64 2, i64 2) #51, !dbg !59: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %.fca.1.1.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 1, !dbg !100: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}, intvals: {}
  %.fca.1.0.gep = getelementptr inbounds { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4, i64 0, i32 1, i32 0, !dbg !100: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Pointer, [-1,0,0,-1]:Float@double, [-1,0,8]:Integer, [-1,0,9]:Integer, [-1,0,10]:Integer, [-1,0,11]:Integer, [-1,0,12]:Integer, [-1,0,13]:Integer, [-1,0,14]:Integer, [-1,0,15]:Integer, [-1,0,16]:Integer, [-1,0,17]:Integer, [-1,0,18]:Integer, [-1,0,19]:Integer, [-1,0,20]:Integer, [-1,0,21]:Integer, [-1,0,22]:Integer, [-1,0,23]:Integer, [-1,0,24]:Integer, [-1,0,25]:Integer, [-1,0,26]:Integer, [-1,0,27]:Integer, [-1,0,28]:Integer, [-1,0,29]:Integer, [-1,0,30]:Integer, [-1,0,31]:Integer, [-1,0,32]:Integer, [-1,0,33]:Integer, [-1,0,34]:Integer, [-1,0,35]:Integer, [-1,0,36]:Integer, [-1,0,37]:Integer, [-1,0,38]:Integer, [-1,0,39]:Integer}, intvals: {}
  %20 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* @julia.gc_alloc_obj(i8* %ptls_load2021, i64 8, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 4694585776 to {}*) to {} addrspace(10)*)) #52, !dbg !88: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %18 = freeze i64 %17, !dbg !85: {[-1]:Integer}, intvals: {}
  %.fca.1.load = load i32, i32* %.fca.1.gep, align 8, !dbg !98: {[-1]:Integer}, intvals: {}
  %57 = sitofp i64 %56 to double, !dbg !124: {[-1]:Float@double}, intvals: {}
  %25 = load i64, i64 addrspace(11)* %24, align 8, !tbaa !84: {}, intvals: {}
  %62 = fptosi double %57 to i64, !dbg !135: {[-1]:Integer}, intvals: {}
  %37 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %36, align 8, !dbg !62, !tbaa !65, !alias.scope !95, !nonnull !4: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
  %54 = bitcast {} addrspace(10)* addrspace(11)* %53 to i64 addrspace(11)*, !dbg !118: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}, intvals: {}
  %50 = load atomic {} addrspace(10)*, {} addrspace(10)** %49 unordered, align 8, !dbg !109, !tbaa !114, !nonnull !4, !dereferenceable !116, !align !117: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %35 = bitcast {} addrspace(10)* %6 to double addrspace(13)* addrspace(10)*, !dbg !62: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %51 = bitcast {} addrspace(10)* %50 to {} addrspace(10)* addrspace(10)*, !dbg !118: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %31 = load i64, i64 addrspace(11)* %30, align 8, !dbg !62, !tbaa !65, !range !69: {[-1]:Integer}, intvals: {}
  %63 = freeze i64 %62, !dbg !135: {[-1]:Integer}, intvals: {}
  %12 = load double, double addrspace(11)* %67, align 8, !dbg !70, !tbaa !84: {[-1]:Float@double}, intvals: {}
  %10 = bitcast {} addrspace(10)* addrspace(11)* %9 to i64 addrspace(11)*, !dbg !62: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}, intvals: {}
  %.fca.2.load = load i64, i64* %.fca.2.gep14, align 8, !dbg !98: {[-1]:Integer}, intvals: {}
  %24 = bitcast double addrspace(11)* %67 to i64 addrspace(11)*: {[-1]:Pointer}, intvals: {}
  %8 = addrspacecast {} addrspace(10)* addrspace(10)* %7 to {} addrspace(10)* addrspace(11)*, !dbg !62: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %26 = zext i1 %66 to i8, !dbg !80: {[-1]:Anything}, intvals: {}
  %11 = load i64, i64 addrspace(11)* %10, align 8, !dbg !62, !tbaa !65, !range !69: {[-1]:Integer}, intvals: {}
  %7 = bitcast {} addrspace(10)* %6 to {} addrspace(10)* addrspace(10)*, !dbg !62: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %36 = addrspacecast double addrspace(13)* addrspace(10)* %35 to double addrspace(13)* addrspace(11)*, !dbg !62: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %27 = addrspacecast { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }* %4 to { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 } addrspace(11)*, !dbg !100: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Pointer, [-1,8,0]:Pointer, [-1,8,0,-1]:Float@double, [-1,8,8]:Integer, [-1,8,9]:Integer, [-1,8,10]:Integer, [-1,8,11]:Integer, [-1,8,12]:Integer, [-1,8,13]:Integer, [-1,8,14]:Integer, [-1,8,15]:Integer, [-1,8,16]:Integer, [-1,8,17]:Integer, [-1,8,18]:Integer, [-1,8,19]:Integer, [-1,8,20]:Integer, [-1,8,21]:Integer, [-1,8,22]:Integer, [-1,8,23]:Integer, [-1,8,24]:Integer, [-1,8,25]:Integer, [-1,8,26]:Integer, [-1,8,27]:Integer, [-1,8,28]:Integer, [-1,8,29]:Integer, [-1,8,30]:Integer, [-1,8,31]:Integer, [-1,8,32]:Integer, [-1,8,33]:Integer, [-1,8,34]:Integer, [-1,8,35]:Integer, [-1,8,36]:Integer, [-1,8,37]:Integer, [-1,8,38]:Integer, [-1,8,39]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Integer}, intvals: {}
  %52 = addrspacecast {} addrspace(10)* addrspace(10)* %51 to {} addrspace(10)* addrspace(11)*, !dbg !118: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
  %30 = bitcast {} addrspace(10)* addrspace(11)* %29 to i64 addrspace(11)*, !dbg !62: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %55 = load i64, i64 addrspace(11)* %54, align 8, !dbg !118, !tbaa !65, !range !69: {[-1]:Integer}, intvals: {}
  %17 = fptosi double %12 to i64, !dbg !85: {[-1]:Integer}, intvals: {}
  %.0.sroa_cast1 = addrspacecast i64* %3 to double addrspace(11)*, !dbg !80: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}, intvals: {}
  %value_phi10 = phi i64 [ %18, %L34 ], [ %25, %L44 ]: {}, intvals: {}
  %61 = and i1 %59, %60, !dbg !132: {[-1]:Integer}, intvals: {}
  %56 = add nsw i64 %55, -1, !dbg !120: {[-1]:Integer}, intvals: {}
  %60 = fcmp olt double %57, 0x43E0000000000000, !dbg !127: {[-1]:Integer}, intvals: {}
  %59 = icmp eq i64 %56, 7, !dbg !130: {[-1]:Integer}, intvals: {}
  %64 = icmp slt i64 %63, %55, !dbg !136: {[-1]:Integer}, intvals: {}
  %66 = or i1 %58, %65, !dbg !138: {[-1]:Integer}, intvals: {}
  %47 = add nuw nsw i64 %11, 1, !dbg !107: {[-1]:Integer}, intvals: {}
  %65 = and i1 %61, %64, !dbg !132: {[-1]:Integer}, intvals: {}
  %58 = icmp ugt i64 %55, 8, !dbg !127: {[-1]:Integer}, intvals: {}
  %13 = fcmp ult double %12, 0xC3E0000000000000, !dbg !70: {[-1]:Integer}, intvals: {}
  %value_phi.off0 = or i1 %13, %14, !dbg !73: {[-1]:Integer}, intvals: {}
  %14 = fcmp uge double %12, 0x43E0000000000000, !dbg !73: {[-1]:Integer}, intvals: {}
  %16 = fcmp une double %15, %12: {[-1]:Integer}, intvals: {}
  %.not = icmp eq i64 %11, 0, !dbg !62: {[-1]:Integer}, intvals: {}
  %.not24 = icmp eq i64 %31, 1, !dbg !103: {[-1]:Integer}, intvals: {}
  %.not15 = icmp eq i64 %31, 0, !dbg !62: {[-1]:Integer}, intvals: {}
  %42 = icmp ugt i64 %11, 1, !dbg !105: {[-1]:Integer}, intvals: {}
  %or.cond = or i1 %value_phi.off0, %16, !dbg !73: {[-1]:Integer}, intvals: {}
@jl_invoke: {[-1]:Pointer}, intvals: {}
@_j_const1 = private unnamed_addr constant double 7.000000e+00: {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
double 5.000000e-01: {[-1]:Float@double}, intvals: {}
double 0xC3E0000000000000: {[-1]:Float@double}, intvals: {}
double 0x43E0000000000000: {[-1]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 4694585776 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
{}* inttoptr (i64 4694585776 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 4747176656 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
{}* inttoptr (i64 4747176656 to {}*): {[-1]:Anything}, intvals: {}
{}* inttoptr (i64 4693385024 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 4693385024 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
double 1.000000e+00: {[-1]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 13116723440 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
{}* inttoptr (i64 13116723440 to {}*): {[-1]:Anything}, intvals: {}
double addrspace(11)* addrspacecast (double* @_j_const1 to double addrspace(11)*): {[-1]:Pointer, [-1,-1]:Float@double}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 13142459984 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
{}* inttoptr (i64 13142459984 to {}*): {[-1]:Anything}, intvals: {}
double 7.000000e+00: {[-1]:Float@double}, intvals: {}
{} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*)* bitcast ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32, {} addrspace(10)*)* @jl_invoke to {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*)*): {[-1]:Pointer}, intvals: {}
{}* inttoptr (i64 4339842360 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 4339842360 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
i64 7: {[-1]:Integer}, intvals: {7,}
i64 0: {[-1]:Anything}, intvals: {0,}
i64 1: {[-1]:Integer}, intvals: {1,}
i64 8: {[-1]:Integer}, intvals: {8,}
i64 -1: {[-1]:Anything}, intvals: {-1,}
  %4 = alloca { [1 x double], { {} addrspace(10)*, i32, i64 }, i64, i8 }, align 8: {[-1]:Pointer, [-1,0]:Float@double, [-1,8]:Pointer, [-1,8,0]:Pointer, [-1,8,0,-1]:Float@double, [-1,8,8]:Integer, [-1,8,9]:Integer, [-1,8,10]:Integer, [-1,8,11]:Integer, [-1,8,12]:Integer, [-1,8,13]:Integer, [-1,8,14]:Integer, [-1,8,15]:Integer, [-1,8,16]:Integer, [-1,8,17]:Integer, [-1,8,18]:Integer, [-1,8,19]:Integer, [-1,8,20]:Integer, [-1,8,21]:Integer, [-1,8,22]:Integer, [-1,8,23]:Integer, [-1,8,24]:Integer, [-1,8,25]:Integer, [-1,8,26]:Integer, [-1,8,27]:Integer, [-1,8,28]:Integer, [-1,8,29]:Integer, [-1,8,30]:Integer, [-1,8,31]:Integer, [-1,8,32]:Integer, [-1,8,33]:Integer, [-1,8,34]:Integer, [-1,8,35]:Integer, [-1,8,36]:Integer, [-1,8,37]:Integer, [-1,8,38]:Integer, [-1,8,39]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer, [-1,40]:Integer}, intvals: {}
  %1 = alloca { {} addrspace(10)*, i32, i64 }, align 8: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Pointer, [-1,0,0,-1]:Float@double, [-1,0,8]:Integer, [-1,0,9]:Integer, [-1,0,10]:Integer, [-1,0,11]:Integer, [-1,0,12]:Integer, [-1,0,13]:Integer, [-1,0,14]:Integer, [-1,0,15]:Integer, [-1,0,16]:Integer, [-1,0,17]:Integer, [-1,0,18]:Integer, [-1,0,19]:Integer, [-1,0,20]:Integer, [-1,0,21]:Integer, [-1,0,22]:Integer, [-1,0,23]:Integer, [-1,0,24]:Integer, [-1,0,25]:Integer, [-1,0,26]:Integer, [-1,0,27]:Integer, [-1,0,28]:Integer, [-1,0,29]:Integer, [-1,0,30]:Integer, [-1,0,31]:Integer, [-1,0,32]:Integer, [-1,0,33]:Integer, [-1,0,34]:Integer, [-1,0,35]:Integer, [-1,0,36]:Integer, [-1,0,37]:Integer, [-1,0,38]:Integer, [-1,0,39]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer}, intvals: {}
  %3 = alloca i64, align 8: {[-1]:Pointer, [-1,-1]:Integer}, intvals: {}
  %2 = alloca [1 x {} addrspace(10)*], align 8: {[-1]:Pointer}, intvals: {}
{} addrspace(10)* %0: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}, intvals: {}
</analysis>

Illegal updateAnalysis prev:{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer} new: {[-1]:Pointer, [-1,0]:Float@double}
val:   %.0.sroa_cast1 = addrspacecast i64* %3 to double addrspace(11)*, !dbg !80 origin=  %67 = select i1 %66, double addrspace(11)* addrspacecast (double* @_j_const1 to double addrspace(11)*), double addrspace(11)* %.0.sroa_cast1, !dbg !80
MethodInstance for Main.MWE.f(::Matrix{Float64})


Caused by:
Stacktrace:
 [1] Wishart
   @ ~/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:19
 [2] Wishart
   @ ~/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:24
 [3] f
   @ ~/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:38

Stacktrace:
  [1] julia_error(cstr::Cstring, val::Ptr{LLVM.API.LLVMOpaqueValue}, errtype::Enzyme.API.ErrorType, data::Ptr{Nothing}, data2::Ptr{LLVM.API.LLVMOpaqueValue}, B::Ptr{LLVM.API.LLVMOpaqueBuilder})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:2306
  [2] EnzymeCreatePrimalAndGradient(logic::Enzyme.Logic, todiff::LLVM.Function, retType::Enzyme.API.CDIFFE_TYPE, constant_args::Vector{Enzyme.API.CDIFFE_TYPE}, TA::Enzyme.TypeAnalysis, returnValue::Bool, dretUsed::Bool, mode::Enzyme.API.CDerivativeMode, width::Int64, additionalArg::Ptr{Nothing}, forceAnonymousTape::Bool, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{Bool}, augmented::Ptr{Nothing}, atomicAdd::Bool)
    @ Enzyme.API ~/.julia/packages/Enzyme/TiboG/src/api.jl:163
  [3] enzyme!(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, mod::LLVM.Module, primalf::LLVM.Function, TT::Type, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, wrap::Bool, modifiedBetween::Tuple{Bool, Bool}, returnPrimal::Bool, expectedTapeType::Type, loweredArgs::Set{Int64}, boxedArgs::Set{Int64})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:4168
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, toplevel::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:6438
  [5] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool) (repeats 2 times)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7241
  [6] cached_compilation
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7282 [inlined]
  [7] thunkbase(ctx::LLVM.Context, mi::Core.MethodInstance, #unused#::Val{0x0000000000007a74}, #unused#::Type{EnzymeCore.Const{typeof(Main.MWE.f)}}, #unused#::Type{EnzymeCore.Active}, tt::Type{Tuple{EnzymeCore.Duplicated{Matrix{Float64}}}}, #unused#::Val{Enzyme.API.DEM_ReverseModeCombined}, #unused#::Val{1}, #unused#::Val{(false, false)}, #unused#::Val{false}, #unused#::Val{false}, #unused#::Type{EnzymeCore.FFIABI}, #unused#::Val{true})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7355
  [8] #s2001#19000
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7407 [inlined]
  [9] var"#s2001#19000"(FA::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, ReturnPrimal::Any, ShadowInit::Any, World::Any, ABI::Any, ErrIfFuncWritten::Any, ::Any, #unused#::Type, #unused#::Type, #unused#::Type, tt::Any, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Type, #unused#::Any)
    @ Enzyme.Compiler ./none:0
 [10] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core ./boot.jl:580
 [11] autodiff
    @ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:315 [inlined]
 [12] autodiff
    @ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:332 [inlined]
 [13] gradient(rm::EnzymeCore.ReverseMode{false, EnzymeCore.FFIABI, false, false}, f::typeof(Main.MWE.f), x::Matrix{Float64})
    @ Enzyme ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:1049
 [14] top-level scope
    @ ~/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:47
 [15] include(fname::String)
    @ Base.MainInclude ./client.jl:451
 [16] top-level scope
    @ REPL[1]:1
in expression starting at /Users/mhauru/projects/Enzyme-mwes/wishart_segfault/mwe_segfault2.jl:3

Can we reopen please?

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

3 participants