EnzymeAD / Enzyme.jl

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

triu! Illegal Type Analysis #1159

Closed matinraayai closed 6 months ago

matinraayai commented 11 months ago

I'm trying to run the following code which can be found here

using Redbird
using SparseArrays
import Redbird.JlMatBindings as JlMat
using MATLAB
using Debugger
using Enzyme

function cart2bary_enzyme(node::Array{Float64}, elem::Array{Int}, 
                         optode::Array{Float64},
                         b::Array{Float64})
    mi = size(optode, 1)                     
    ni = collect(1:mi)
    b[:] = Redbird.iso2mesh.cart2bary(node[elem[1, :], :], optode[ni, :])
    return nothing
end

function main()    
    prop = [0     0 1 1
            0.008 1 0 1.37
            0.016 1 0 1.37]
    prop = reshape(prop, 1, size(prop)...)

    cfg = Redbird.Structs.RBConfigJL()

    cfg.node, cfg.face, cfg.elem = JlMat.meshabox([0 0 0], [60 60 30], 1)
    cfg.seg = ones(Int, size(cfg.elem, 1), 1)

    (xi, yi) = mxcall(:meshgrid, 2, 60:20:140,20:20:100)

    cfg.srcpos = Float64.(hcat(xi[:], yi[:], zeros(length(yi), 1)))
    cfg.detpos = Float64.(hcat(xi[:], yi[:], 60 * ones(length(yi), 1)))
    cfg.srcdir = Float64.([0. 0. 1.])
    cfg.detdir = Float64.([0. 0. -1.])

    cfg.wavelengths = [""]

    cfg = Redbird.Forward.rbmeshprep(cfg, prop)
    node = cfg.node
    elem = cfg.elem
    srcpos = cfg.srcpos
    srcdir = Float64.(cfg.srcdir)
    detpos = cfg.detpos
    detdir = Float64.(cfg.detdir)

    face = cfg.face
    wavelengths = cfg.wavelengths
    seg = cfg.seg

    b = zeros(Float64, 50, 4)
    ∂b = zeros(Float64, 50, 4)
    bkprop = Redbird.Forward.rbgetbulk(node, elem, face, seg, wavelengths, prop) 
    (optode, widesrc) = Redbird.Forward.rbgetoptodes(node, bkprop, srcpos, srcdir, detpos, detdir)
    mi = size(optode, 1)                     
    ni = collect(1:mi)
    @show size(node[elem[1, :], :])
    @show size(optode[ni, :])
    @show size(Redbird.iso2mesh.cart2bary(node[elem[1, :], :], optode[ni, :]))

    Enzyme.autodiff(Reverse, cart2bary_enzyme,
    Const(node), Const(elem), Const(optode), Duplicated(b, ∂b))
    @show sum(newloc), sum(∂newloc)

end

main()

When I do that, Enzyme throws the following error in Julia 1.10.0:

┌ Warning: Using fallback BLAS replacements, performance may be degraded
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/U36Ed/src/utils.jl:59
┌ Warning: Using fallback BLAS replacements, performance may be degraded
└ @ Enzyme.Compiler ~/.julia/packages/GPUCompiler/U36Ed/src/utils.jl:59
ERROR: LoadError: Enzyme compilation failed due to illegal type analysis.
Current scope: 
; Function Attrs: mustprogress willreturn
define internal fastcc nonnull {} addrspace(10)* @preprocess_julia_getproperty_5555([3 x {} addrspace(10)*] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(24) %0) unnamed_addr #134 !dbg !12861 {
top:
  %1 = call noalias nonnull dereferenceable(16) dereferenceable_or_null(16) i8* @malloc(i64 16), !enzyme_fromstack !5442
  %newstruct7 = bitcast i8* %1 to [2 x i64]*, !enzyme_caststack !111
  %2 = call noalias nonnull dereferenceable(16) dereferenceable_or_null(16) i8* @malloc(i64 16), !enzyme_fromstack !5442
  %newstruct = bitcast i8* %2 to [2 x i64]*, !enzyme_caststack !111
  %3 = call noalias nonnull dereferenceable(32) dereferenceable_or_null(32) i8* @malloc(i64 32), !enzyme_fromstack !5442
  %newstruct9 = bitcast i8* %3 to [2 x [2 x i64]]*, !enzyme_caststack !111
  %4 = call {}*** @julia.get_pgcstack() #135
  %ptls_field68 = getelementptr inbounds {}**, {}*** %4, i64 2
  %5 = bitcast {}*** %ptls_field68 to i64***
  %ptls_load6970 = load i64**, i64*** %5, align 8, !tbaa !112
  %6 = getelementptr inbounds i64*, i64** %ptls_load6970, i64 2
  %safepoint = load i64*, i64** %6, align 8, !tbaa !116, !invariant.load !111
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #135, !dbg !12862
  fence syncscope("singlethread") seq_cst
  %getfield_addr = getelementptr inbounds [3 x {} addrspace(10)*], [3 x {} addrspace(10)*] addrspace(11)* %0, i64 0, i64 0, !dbg !12863
  %getfield = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %getfield_addr unordered, align 8, !dbg !12863, !tbaa !116, !invariant.load !111, !alias.scope !123, !noalias !126, !nonnull !111, !dereferenceable !137, !align !138
  br i1 icmp eq ({} addrspace(11)* addrspacecast ({}* inttoptr (i64 47832111324376 to {}*) to {} addrspace(11)*), {} addrspace(11)* addrspacecast ({}* inttoptr (i64 47832110943416 to {}*) to {} addrspace(11)*)), label %L6, label %L73, !dbg !12865

L6:                                               ; preds = %top
  %7 = bitcast {} addrspace(10)* %getfield to {} addrspace(10)* addrspace(10)*, !dbg !12866
  %8 = addrspacecast {} addrspace(10)* addrspace(10)* %7 to {} addrspace(10)* addrspace(11)*, !dbg !12866
  %arraysize_ptr2 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 4, !dbg !12866
  %9 = bitcast {} addrspace(10)* addrspace(11)* %arraysize_ptr2 to i64 addrspace(11)*, !dbg !12866
  %arraysize3 = load i64, i64 addrspace(11)* %9, align 8, !dbg !12866, !tbaa !116, !range !134, !invariant.load !111, !alias.scope !123, !noalias !126
  %arraysize_ptr = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 3, !dbg !12866
  %10 = bitcast {} addrspace(10)* addrspace(11)* %arraysize_ptr to i64 addrspace(11)*, !dbg !12866
  %arraysize = load i64, i64 addrspace(11)* %10, align 8, !dbg !12866, !tbaa !116, !range !134, !invariant.load !111, !alias.scope !123, !noalias !126
  %11 = call i64 @llvm.umin.i64(i64 %arraysize3, i64 %arraysize) #135, !dbg !12867
  %memcpy_refined_dst = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct, i64 0, i64 0, !dbg !12870
  store i64 1, i64* %memcpy_refined_dst, align 8, !dbg !12870, !tbaa !302, !alias.scope !304, !noalias !12872
  %12 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct, i64 0, i64 1, !dbg !12870
  store i64 %11, i64* %12, align 8, !dbg !12870, !tbaa !302, !alias.scope !304, !noalias !12872
  %memcpy_refined_dst8 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct7, i64 0, i64 0, !dbg !12870
  store i64 1, i64* %memcpy_refined_dst8, align 8, !dbg !12870, !tbaa !302, !alias.scope !304, !noalias !12872
  %13 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct7, i64 0, i64 1, !dbg !12870
  store i64 %arraysize3, i64* %13, align 8, !dbg !12870, !tbaa !302, !alias.scope !304, !noalias !12872
  %14 = bitcast [2 x [2 x i64]]* %newstruct9 to i8*, !dbg !12875
  %15 = bitcast [2 x i64]* %newstruct to i8*, !dbg !12875
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(16) %14, i8* noundef nonnull align 8 dereferenceable(16) %15, i64 noundef 16, i1 noundef false) #135, !dbg !12875, !tbaa !302, !alias.scope !304, !noalias !12872
  %16 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %newstruct9, i64 0, i64 1, !dbg !12875
  %17 = bitcast [2 x i64]* %16 to i8*, !dbg !12875
  %18 = bitcast [2 x i64]* %newstruct7 to i8*, !dbg !12875
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(16) %17, i8* noundef nonnull align 8 dereferenceable(16) %18, i64 noundef 16, i1 noundef false) #135, !dbg !12875, !tbaa !302, !alias.scope !304, !noalias !12872
  %19 = icmp eq i64 %11, 0, !dbg !12878
  %20 = add nsw i64 %11, -1, !dbg !12885
  %21 = icmp ult i64 %20, %arraysize, !dbg !12887
  %22 = or i1 %19, %21, !dbg !12888
  br i1 %22, label %L62, label %L59, !dbg !12884

L59:                                              ; preds = %L6
  %23 = addrspacecast [2 x [2 x i64]]* %newstruct9 to [2 x [2 x i64]] addrspace(11)*, !dbg !12884
  call fastcc void @julia_throw_boundserror_5527({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %getfield, [2 x [2 x i64]] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(32) %23) #136, !dbg !12884
  unreachable, !dbg !12884

L62:                                              ; preds = %L6
  %24 = addrspacecast [2 x i64]* %newstruct to [2 x i64] addrspace(11)*, !dbg !12889
  %25 = addrspacecast [2 x i64]* %newstruct7 to [2 x i64] addrspace(11)*, !dbg !12889
  %26 = call fastcc nonnull {} addrspace(10)* @julia__unsafe_getindex_5562({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %getfield, [2 x i64] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %24, [2 x i64] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %25) #135, !dbg !12889
  %27 = call fastcc nonnull {} addrspace(10)* @julia_triu__5560({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %26) #135, !dbg !12890
  br label %common.ret

common.ret:                                       ; preds = %L73, %L62
  %common.ret.op = phi {} addrspace(10)* [ %27, %L62 ], [ %box, %L73 ]
  ret {} addrspace(10)* %common.ret.op, !dbg !12891

L73:                                              ; preds = %top
  %getfield_addr18 = getelementptr inbounds [3 x {} addrspace(10)*], [3 x {} addrspace(10)*] addrspace(11)* %0, i64 0, i64 1, !dbg !12892
  %getfield19 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %getfield_addr18 unordered, align 8, !dbg !12892, !tbaa !116, !invariant.load !111, !alias.scope !123, !noalias !126, !nonnull !111, !dereferenceable !137, !align !138
  %current_task2175 = getelementptr inbounds {}**, {}*** %4, i64 -14, !dbg !12893
  %current_task21 = bitcast {}*** %current_task2175 to {}**, !dbg !12893
  %box = call noalias nonnull dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task21, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47836955377104 to {}*) to {} addrspace(10)*)) #137, !dbg !12893
  %28 = bitcast {} addrspace(10)* %box to [2 x {} addrspace(10)*] addrspace(10)*, !dbg !12893
  %.repack = getelementptr inbounds [2 x {} addrspace(10)*], [2 x {} addrspace(10)*] addrspace(10)* %28, i64 0, i64 0, !dbg !12893
  store {} addrspace(10)* %getfield, {} addrspace(10)* addrspace(10)* %.repack, align 8, !dbg !12893, !tbaa !153, !alias.scope !157, !noalias !12894
  %.repack76 = getelementptr inbounds [2 x {} addrspace(10)*], [2 x {} addrspace(10)*] addrspace(10)* %28, i64 0, i64 1, !dbg !12893
  store {} addrspace(10)* %getfield19, {} addrspace(10)* addrspace(10)* %.repack76, align 8, !dbg !12893, !tbaa !153, !alias.scope !157, !noalias !12894
  br label %common.ret
}

 Type analysis state: 
<analysis>
i64 1: {[-1]:Integer}, intvals: {1,}
i64 16: {[-1]:Integer}, intvals: {16,}
i64 0: {[-1]:Anything}, intvals: {0,}
i64 -1: {[-1]:Anything}, intvals: {-1,}
{}* inttoptr (i64 47836955377104 to {}*): {[-1]:Anything}, intvals: {}
{} addrspace(10)* addrspacecast ({}* inttoptr (i64 47836955377104 to {}*) to {} addrspace(10)*): {[-1]:Anything}, intvals: {}
  %24 = addrspacecast [2 x i64]* %newstruct to [2 x i64] addrspace(11)*, !dbg !185: {[-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: {}
  %25 = addrspacecast [2 x i64]* %newstruct7 to [2 x i64] addrspace(11)*, !dbg !185: {[-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: {}
  %26 = call fastcc nonnull {} addrspace(10)* @julia__unsafe_getindex_5562({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %getfield, [2 x i64] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %24, [2 x i64] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) %25) #135, !dbg !185: {[-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 = call fastcc nonnull {} addrspace(10)* @julia_triu__5560({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %26) #135, !dbg !186: {[-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: {}
  %common.ret.op = phi {} addrspace(10)* [ %27, %L62 ], [ %box, %L73 ]: {[-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]: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}, intvals: {}
[3 x {} addrspace(10)*] addrspace(11)* %0: {[-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]: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]:Pointer, [-1,16,0]:Pointer, [-1,16,0,-1]:Integer, [-1,16,8]:Integer, [-1,16,9]:Integer, [-1,16,10]:Integer, [-1,16,11]:Integer, [-1,16,12]:Integer, [-1,16,13]:Integer, [-1,16,14]:Integer, [-1,16,15]:Integer, [-1,16,16]:Integer, [-1,16,17]:Integer, [-1,16,18]:Integer, [-1,16,19]:Integer, [-1,16,20]:Integer, [-1,16,21]:Integer, [-1,16,22]:Integer, [-1,16,23]:Integer, [-1,16,24]:Integer, [-1,16,25]:Integer, [-1,16,26]:Integer, [-1,16,27]:Integer, [-1,16,28]:Integer, [-1,16,29]:Integer, [-1,16,30]:Integer, [-1,16,31]:Integer, [-1,16,32]:Integer, [-1,16,33]:Integer, [-1,16,34]:Integer, [-1,16,35]:Integer, [-1,16,36]:Integer, [-1,16,37]:Integer, [-1,16,38]:Integer, [-1,16,39]:Integer}, intvals: {}
  %2 = call noalias nonnull dereferenceable(16) dereferenceable_or_null(16) i8* @malloc(i64 16), !enzyme_fromstack !112: {[-1]:Pointer}, intvals: {}
  %1 = call noalias nonnull dereferenceable(16) dereferenceable_or_null(16) i8* @malloc(i64 16), !enzyme_fromstack !112: {[-1]:Pointer}, intvals: {}
  %3 = call noalias nonnull dereferenceable(32) dereferenceable_or_null(32) i8* @malloc(i64 32), !enzyme_fromstack !112: {[-1]:Pointer}, intvals: {}
  %4 = call {}*** @julia.get_pgcstack() #135: {}, intvals: {}
  %ptls_field68 = getelementptr inbounds {}**, {}*** %4, i64 2: {}, intvals: {}
  %5 = bitcast {}*** %ptls_field68 to i64***: {[-1]:Pointer}, intvals: {}
  %ptls_load6970 = load i64**, i64*** %5, align 8, !tbaa !113: {}, intvals: {}
  %6 = getelementptr inbounds i64*, i64** %ptls_load6970, i64 2: {[-1]:Pointer}, intvals: {}
  %safepoint = load i64*, i64** %6, align 8, !tbaa !117, !invariant.load !111: {}, intvals: {}
  %getfield_addr = getelementptr inbounds [3 x {} addrspace(10)*], [3 x {} addrspace(10)*] addrspace(11)* %0, i64 0, i64 0, !dbg !120: {[-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: {}
  %getfield = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %getfield_addr unordered, align 8, !dbg !120, !tbaa !117, !invariant.load !111, !alias.scope !123, !noalias !126, !nonnull !111, !dereferenceable !131, !align !132: {[-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: {}
  %box = call noalias nonnull dereferenceable(16) {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task21, i64 noundef 16, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47836955377104 to {}*) to {} addrspace(10)*)) #137, !dbg !192: {[-1,-1]:Pointer, [-1,-1,0]:Pointer, [-1,-1,0,-1]:Float@double, [-1,-1,8]:Integer, [-1,-1,9]:Integer, [-1,-1,10]:Integer, [-1,-1,11]:Integer, [-1,-1,12]:Integer, [-1,-1,13]:Integer, [-1,-1,14]:Integer, [-1,-1,15]:Integer, [-1,-1,16]:Integer, [-1,-1,17]:Integer, [-1,-1,18]:Integer, [-1,-1,19]:Integer, [-1,-1,20]:Integer, [-1,-1,21]:Integer, [-1,-1,22]:Integer, [-1,-1,23]:Integer, [-1,-1,24]:Integer, [-1,-1,25]:Integer, [-1,-1,26]:Integer, [-1,-1,27]:Integer, [-1,-1,28]:Integer, [-1,-1,29]:Integer, [-1,-1,30]:Integer, [-1,-1,31]:Integer, [-1,-1,32]:Integer, [-1,-1,33]:Integer, [-1,-1,34]:Integer, [-1,-1,35]:Integer, [-1,-1,36]:Integer, [-1,-1,37]:Integer, [-1,-1,38]:Integer, [-1,-1,39]:Integer}, intvals: {}
  %memcpy_refined_dst = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct, i64 0, i64 0, !dbg !145: {[-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: {}
  %12 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct, i64 0, i64 1, !dbg !145: {[-1]:Pointer}, intvals: {}
  %memcpy_refined_dst8 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct7, i64 0, i64 0, !dbg !145: {[-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: {}
  %13 = getelementptr inbounds [2 x i64], [2 x i64]* %newstruct7, i64 0, i64 1, !dbg !145: {[-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: {}
  %14 = bitcast [2 x [2 x i64]]* %newstruct9 to i8*, !dbg !156: {[-1]:Pointer}, intvals: {}
  %15 = bitcast [2 x i64]* %newstruct to i8*, !dbg !156: {[-1]:Pointer}, intvals: {}
  %16 = getelementptr inbounds [2 x [2 x i64]], [2 x [2 x i64]]* %newstruct9, i64 0, i64 1, !dbg !156: {[-1]:Pointer}, intvals: {}
  %17 = bitcast [2 x i64]* %16 to i8*, !dbg !156: {[-1]:Pointer}, intvals: {}
  %18 = bitcast [2 x i64]* %newstruct7 to i8*, !dbg !156: {[-1]:Pointer}, intvals: {}
  %7 = bitcast {} addrspace(10)* %getfield to {} addrspace(10)* addrspace(10)*, !dbg !134: {[-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: {}
  %8 = addrspacecast {} addrspace(10)* addrspace(10)* %7 to {} addrspace(10)* addrspace(11)*, !dbg !134: {[-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: {}
  %arraysize_ptr2 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 4, !dbg !134: {[-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: {}
  %9 = bitcast {} addrspace(10)* addrspace(11)* %arraysize_ptr2 to i64 addrspace(11)*, !dbg !134: {[-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: {}
  %arraysize3 = load i64, i64 addrspace(11)* %9, align 8, !dbg !134, !tbaa !117, !range !137, !invariant.load !111, !alias.scope !123, !noalias !126: {[-1]:Integer}, intvals: {}
  %arraysize_ptr = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %8, i64 3, !dbg !134: {[-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: {}
  %11 = call i64 @llvm.umin.i64(i64 %arraysize3, i64 %arraysize) #135, !dbg !138: {}, intvals: {}
  %newstruct9 = bitcast i8* %3 to [2 x [2 x i64]]*, !enzyme_caststack !111: {[-1]:Pointer}, intvals: {}
  %10 = bitcast {} addrspace(10)* addrspace(11)* %arraysize_ptr to i64 addrspace(11)*, !dbg !134: {[-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: {}
  %arraysize = load i64, i64 addrspace(11)* %10, align 8, !dbg !134, !tbaa !117, !range !137, !invariant.load !111, !alias.scope !123, !noalias !126: {[-1]:Integer}, intvals: {}
  %newstruct7 = bitcast i8* %1 to [2 x i64]*, !enzyme_caststack !111: {[-1]:Pointer}, intvals: {}
  %19 = icmp eq i64 %11, 0, !dbg !164: {[-1]:Integer}, intvals: {}
  %20 = add nsw i64 %11, -1, !dbg !178: {[-1]:Integer}, intvals: {}
  %21 = icmp ult i64 %20, %arraysize, !dbg !181: {[-1]:Integer}, intvals: {}
  %22 = or i1 %19, %21, !dbg !182: {[-1]:Integer}, intvals: {}
  %current_task21 = bitcast {}*** %current_task2175 to {}**, !dbg !192: {}, intvals: {}
  %newstruct = bitcast i8* %2 to [2 x i64]*, !enzyme_caststack !111: {[-1]:Pointer}, intvals: {}
</analysis>

Illegal updateAnalysis prev:{[-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} new: {[-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]: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}
val:   %27 = call fastcc nonnull {} addrspace(10)* @julia_triu__5560({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) %26) #135, !dbg !186 origin=  %common.ret.op = phi {} addrspace(10)* [ %27, %L62 ], [ %box, %L73 ]

Caused by:
Stacktrace:
 [1] triu!
   @ ~/modules/julia/1.10.0/julia-1.10.0-rc1/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:435
 [2] getproperty
   @ ~/modules/julia/1.10.0/julia-1.10.0-rc1/share/julia/stdlib/v1.10/LinearAlgebra/src/qr.jl:489

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/rbuCz/src/compiler.jl:5841
  [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/rbuCz/src/api.jl:141
  [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::NTuple{5, Bool}, returnPrimal::Bool, jlrules::Vector{String}, expectedTapeType::Type, loweredArgs::Set{Int64}, boxedArgs::Set{Int64})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:7726
  [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/rbuCz/src/compiler.jl:9278
  [5] codegen
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:8886 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool) (repeats 2 times)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9830
  [7] cached_compilation
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9864 [inlined]
  [8] (::Enzyme.Compiler.var"#474#475"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, NTuple{5, Bool}, Int64, Bool, Bool, UInt64, DataType})(ctx::LLVM.Context)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9921
  [9] JuliaContext(f::Enzyme.Compiler.var"#474#475"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, NTuple{5, Bool}, Int64, Bool, Bool, UInt64, DataType})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/driver.jl:47
 [10] #s325#473
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9882 [inlined]
 [11] var"#s325#473"(FA::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, ReturnPrimal::Any, ShadowInit::Any, World::Any, ABI::Any, ::Any, ::Type, ::Type, ::Type, tt::Any, ::Type, ::Type, ::Type, ::Type, ::Type, ::Any)
    @ Enzyme.Compiler ./none:0
 [12] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:600
 [13] autodiff(::ReverseMode{false, FFIABI}, ::Const{typeof(cart2bary_enzyme)}, ::Type{Const{Nothing}}, ::Const{Matrix{Float64}}, ::Vararg{Any})
    @ Enzyme ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:207
 [14] autodiff(::ReverseMode{false, FFIABI}, ::Const{typeof(cart2bary_enzyme)}, ::Const{Matrix{Float64}}, ::Const{Matrix{Int64}}, ::Vararg{Any})
    @ Enzyme ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:236
 [15] autodiff
    @ ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:222 [inlined]
 [16] main()
    @ Main /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:64
 [17] top-level scope
    @ /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:70
in expression starting at /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:70

The code is part of Redbird.jl and can be run from the high-level folder of the project via julia --project test/diff/test_cart2bary.jl

wsmoses commented 11 months ago

This is a different error from what you had on slack, and likely indicates a union return

wsmoses commented 11 months ago

You can work around this with Enzyme.API.strictAliasing!(false)

matinraayai commented 11 months ago

@wsmoses I did just that and I'm getting this new error:

Current scope: 
; Function Attrs: mustprogress willreturn
define internal fastcc void @preprocess_julia_laic1__5971([3 x double]* noalias nocapture nofree noundef nonnull writeonly sret([3 x double]) align 8 dereferenceable(24) %0, i64 signext "enzyme_inactive" %1, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(40) %2, double %3, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(48) %4, double %5) unnamed_addr #130 !dbg !11001 {
top:
  %6 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !154
  %7 = bitcast i8* %6 to i64*, !enzyme_caststack !111
  %8 = bitcast i64* %7 to i8*
  %9 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !154
  %10 = bitcast i8* %9 to i64*, !enzyme_caststack !111
  %11 = bitcast i64* %10 to i8*
  %12 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !154
  %13 = bitcast i8* %12 to i64*, !enzyme_caststack !111
  %14 = bitcast i64* %13 to i8*
  %15 = call noalias nonnull dereferenceable(8) dereferenceable_or_null(8) i8* @malloc(i64 8), !enzyme_fromstack !154
  %16 = bitcast i8* %15 to i64*, !enzyme_caststack !111
  %17 = bitcast i64* %16 to i8*
  %18 = call {}*** @julia.get_pgcstack() #143
  %ptls_field75 = getelementptr inbounds {}**, {}*** %18, i64 2
  %19 = bitcast {}*** %ptls_field75 to i64***
  %ptls_load7677 = load i64**, i64*** %19, align 8, !tbaa !112
  %20 = getelementptr inbounds i64*, i64** %ptls_load7677, i64 2
  %safepoint = load i64*, i64** %20, align 8, !tbaa !116, !invariant.load !111
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #143, !dbg !11002
  fence syncscope("singlethread") seq_cst
  %21 = getelementptr inbounds { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* %2, i64 0, i32 1, i64 0, i64 0, !dbg !11003
  %22 = getelementptr inbounds { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* %2, i64 0, i32 1, i64 0, i64 1, !dbg !11012
  %unbox = load i64, i64 addrspace(11)* %22, align 8, !dbg !11014, !tbaa !116, !invariant.load !111, !alias.scope !145, !noalias !146
  %unbox2 = load i64, i64 addrspace(11)* %21, align 8, !dbg !11014, !tbaa !116, !invariant.load !111, !alias.scope !145, !noalias !146
  %23 = add i64 %unbox, 1, !dbg !11014
  %24 = sub i64 %23, %unbox2, !dbg !11016
  %25 = call i64 @llvm.smax.i64(i64 %24, i64 noundef 0) #143, !dbg !11017
  %26 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 1, i32 0, i64 0, !dbg !11022
  %27 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 1, i32 0, i64 1, !dbg !11031
  %unbox3 = load i64, i64 addrspace(11)* %27, align 8, !dbg !11033, !tbaa !116, !invariant.load !111, !alias.scope !145, !noalias !146
  %unbox4 = load i64, i64 addrspace(11)* %26, align 8, !dbg !11033, !tbaa !116, !invariant.load !111, !alias.scope !145, !noalias !146
  %28 = add i64 %unbox3, 1, !dbg !11033
  %29 = sub i64 %28, %unbox4, !dbg !11035
  %30 = call i64 @llvm.smax.i64(i64 %29, i64 noundef 0) #143, !dbg !11036
  %.not = icmp eq i64 %25, %30, !dbg !11041
  br i1 %.not, label %L32, label %L20, !dbg !11030

L20:                                              ; preds = %top
  %31 = call noalias nonnull {} addrspace(10)* @ijl_box_int64(i64 signext %25) #144, !dbg !11043
  %32 = call noalias nonnull {} addrspace(10)* @ijl_box_int64(i64 signext %30) #144, !dbg !11043
  %33 = call nonnull {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32, {} addrspace(10)*)*, {} addrspace(10)*, {} addrspace(10)*, ...) @julia.call2({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32, {} addrspace(10)*)* noundef nonnull @ijl_invoke, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648999242224 to {}*) to {} addrspace(10)*), {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974480176 to {}*) to {} addrspace(10)*), {} addrspace(10)* addrspacecast ({}* inttoptr (i64 47649081334208 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %31, {} addrspace(10)* addrspacecast ({}* inttoptr (i64 47649081334160 to {}*) to {} addrspace(10)*), {} addrspace(10)* nonnull %32) #145, !dbg !11043
  %current_task978 = getelementptr inbounds {}**, {}*** %18, i64 -14, !dbg !11043
  %current_task9 = bitcast {}*** %current_task978 to {}**, !dbg !11043
  %box = call noalias nonnull dereferenceable(8) {} addrspace(10)* @julia.gc_alloc_obj({}** nonnull %current_task9, i64 noundef 8, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47649020864352 to {}*) to {} addrspace(10)*)) #146, !dbg !11043
  %34 = bitcast {} addrspace(10)* %box to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !11043
  %35 = getelementptr [1 x {} addrspace(10)*], [1 x {} addrspace(10)*] addrspace(10)* %34, i64 0, i64 0, !dbg !11043
  store {} addrspace(10)* %33, {} addrspace(10)* addrspace(10)* %35, align 8, !dbg !11043, !tbaa !166, !alias.scope !170, !noalias !11044
  %36 = addrspacecast {} addrspace(10)* %box to {} addrspace(12)*, !dbg !11043
  call void @ijl_throw({} addrspace(12)* %36) #147, !dbg !11043
  unreachable, !dbg !11043

L32:                                              ; preds = %top
  %37 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !11047
  %38 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !11049
  %39 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !11051
  call void @llvm.lifetime.start.p0i8(i64 noundef 8, i8* noundef nonnull %8) #143
  store i64 %1, i64* %7, align 16, !dbg !11053, !tbaa !1546, !alias.scope !170, !noalias !11044
  call void @llvm.lifetime.start.p0i8(i64 noundef 8, i8* noundef nonnull %11) #143
  store i64 %25, i64* %10, align 16, !dbg !11053, !tbaa !1546, !alias.scope !170, !noalias !11044
  call void @llvm.lifetime.start.p0i8(i64 noundef 8, i8* noundef nonnull %14) #143
  %40 = bitcast i64* %13 to double*, !dbg !11053
  store double %3, double* %40, align 16, !dbg !11053, !tbaa !1546, !alias.scope !170, !noalias !11044
  call void @llvm.lifetime.start.p0i8(i64 noundef 8, i8* noundef nonnull %17) #143
  %41 = bitcast i64* %16 to double*, !dbg !11053
  store double %5, double* %41, align 16, !dbg !11053, !tbaa !1546, !alias.scope !170, !noalias !11044
  %getfield_addr = getelementptr inbounds { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* %2, i64 0, i32 0, !dbg !11057
  %getfield = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %getfield_addr unordered, align 8, !dbg !11057, !tbaa !116, !alias.scope !145, !noalias !146, !nonnull !111
  %42 = addrspacecast {} addrspace(10)* %getfield to {} addrspace(11)*, !dbg !11059
  %43 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %42) #148, !dbg !11059
  %44 = bitcast {}* %43 to i8**, !dbg !11059
  %arrayptr = load i8*, i8** %44, align 8, !dbg !11059, !tbaa !298, !alias.scope !265, !noalias !266, !nonnull !111
  %45 = shl i64 %unbox2, 3, !dbg !11060
  %46 = add i64 %45, -8, !dbg !11060
  %47 = getelementptr i8, i8* %arrayptr, i64 %46, !dbg !11062
  %48 = ptrtoint i8* %47 to i64, !dbg !11062
  %getfield_addr29 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 0, !dbg !11057
  %getfield30 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %getfield_addr29 unordered, align 8, !dbg !11057, !tbaa !116, !alias.scope !145, !noalias !146, !nonnull !111
  %49 = addrspacecast {} addrspace(10)* %getfield30 to {} addrspace(11)*, !dbg !11059
  %50 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %49) #148, !dbg !11059
  %51 = bitcast {}* %50 to i8**, !dbg !11059
  %arrayptr32 = load i8*, i8** %51, align 8, !dbg !11059, !tbaa !116, !invariant.load !111, !alias.scope !145, !noalias !146, !nonnull !111
  %52 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 1, i32 1, !dbg !11063
  %53 = bitcast {} addrspace(10)* %getfield30 to {} addrspace(10)* addrspace(10)*, !dbg !11065
  %54 = addrspacecast {} addrspace(10)* addrspace(10)* %53 to {} addrspace(10)* addrspace(11)*, !dbg !11065
  %arraysize_ptr = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %54, i64 3, !dbg !11065
  %55 = bitcast {} addrspace(10)* addrspace(11)* %arraysize_ptr to i64 addrspace(11)*, !dbg !11065
  %arraysize = load i64, i64 addrspace(11)* %55, align 8, !dbg !11065, !tbaa !116, !range !150, !invariant.load !111, !alias.scope !145, !noalias !146
  %unbox37 = load i64, i64 addrspace(11)* %52, align 8, !dbg !11069, !tbaa !116, !alias.scope !145, !noalias !146
  %56 = add i64 %unbox37, 2305843009213693951, !dbg !11069
  %57 = mul i64 %56, %arraysize, !dbg !11074
  %58 = add i64 %57, %unbox4, !dbg !11075
  %59 = shl i64 %58, 3, !dbg !11060
  %60 = add i64 %59, -8, !dbg !11060
  %61 = getelementptr i8, i8* %arrayptr32, i64 %60, !dbg !11062
  %62 = ptrtoint i8* %61 to i64, !dbg !11062
  %63 = addrspacecast {} addrspace(10)* %37 to {} addrspace(11)*, !dbg !11076
  %64 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %63) #148, !dbg !11076
  %65 = bitcast {}* %64 to i8**, !dbg !11076
  %arrayptr43 = load i8*, i8** %65, align 8, !dbg !11076, !tbaa !298, !alias.scope !265, !noalias !266, !nonnull !111
  %66 = ptrtoint i8* %arrayptr43 to i64, !dbg !11076
  %67 = addrspacecast {} addrspace(10)* %38 to {} addrspace(11)*, !dbg !11076
  %68 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %67) #148, !dbg !11076
  %69 = bitcast {}* %68 to i8**, !dbg !11076
  %arrayptr45 = load i8*, i8** %69, align 8, !dbg !11076, !tbaa !298, !alias.scope !265, !noalias !266, !nonnull !111
  %70 = ptrtoint i8* %arrayptr45 to i64, !dbg !11076
  %71 = addrspacecast {} addrspace(10)* %39 to {} addrspace(11)*, !dbg !11076
  %72 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %71) #148, !dbg !11076
  %73 = bitcast {}* %72 to i8**, !dbg !11076
  %arrayptr47 = load i8*, i8** %73, align 8, !dbg !11076, !tbaa !298, !alias.scope !265, !noalias !266, !nonnull !111
  %74 = ptrtoint i8* %arrayptr47 to i64, !dbg !11076
  %75 = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } undef, {} addrspace(10)* %getfield30, 0, !dbg !11056
  %76 = insertvalue [2 x i64] undef, i64 %unbox4, 0, !dbg !11056
  %unbox48.unpack84.unpack95 = insertvalue [2 x i64] %76, i64 %unbox3, 1, !dbg !11056
  %77 = insertvalue { [2 x i64], i64 } undef, [2 x i64] %unbox48.unpack84.unpack95, 0, !dbg !11056
  %unbox48.unpack8492 = insertvalue { [2 x i64], i64 } %77, i64 %unbox37, 1, !dbg !11056
  %78 = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %75, { [2 x i64], i64 } %unbox48.unpack8492, 1, !dbg !11056
  %unbox48.elt85 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 2, !dbg !11056
  %unbox48.unpack86 = load i64, i64 addrspace(11)* %unbox48.elt85, align 8, !dbg !11056, !tbaa !116, !alias.scope !145, !noalias !146
  %79 = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %78, i64 %unbox48.unpack86, 2, !dbg !11056
  %unbox48.elt87 = getelementptr inbounds { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* %4, i64 0, i32 3, !dbg !11056
  %unbox48.unpack88 = load i64, i64 addrspace(11)* %unbox48.elt87, align 8, !dbg !11056, !tbaa !116, !alias.scope !145, !noalias !146
  %unbox4889 = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %79, i64 %unbox48.unpack88, 3, !dbg !11056
  %80 = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } undef, {} addrspace(10)* %getfield, 0, !dbg !11056
  %81 = insertvalue [2 x i64] undef, i64 %unbox2, 0, !dbg !11056
  %unbox49.unpack97.unpack106 = insertvalue [2 x i64] %81, i64 %unbox, 1, !dbg !11056
  %unbox49.unpack97103 = insertvalue [1 x [2 x i64]] undef, [2 x i64] %unbox49.unpack97.unpack106, 0, !dbg !11056
  %82 = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %80, [1 x [2 x i64]] %unbox49.unpack97103, 1, !dbg !11056
  %unbox49.elt98 = getelementptr inbounds { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* %2, i64 0, i32 2, !dbg !11056
  %unbox49.unpack99 = load i64, i64 addrspace(11)* %unbox49.elt98, align 8, !dbg !11056, !tbaa !116, !alias.scope !145, !noalias !146
  %83 = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %82, i64 %unbox49.unpack99, 2, !dbg !11056
  %unbox49.elt100 = getelementptr inbounds { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* %2, i64 0, i32 3, !dbg !11056
  %unbox49.unpack101 = load i64, i64 addrspace(11)* %unbox49.elt100, align 8, !dbg !11056, !tbaa !116, !alias.scope !145, !noalias !146
  %unbox49102 = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %83, i64 %unbox49.unpack101, 3, !dbg !11056
  call void @dlaic1_64_(i8* noundef nonnull %8, i8* noundef nonnull %11, i64 %48, i8* noundef nonnull %14, i64 %62, i8* noundef nonnull %17, i64 %66, i64 %70, i64 %74) #143 [ "jl_roots"({} addrspace(10)* %39, {} addrspace(10)* %38, {} addrspace(10)* %37, {} addrspace(10)* null, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %unbox4889, {} addrspace(10)* null, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %unbox49102, {} addrspace(10)* null, {} addrspace(10)* null) ], !dbg !11056
  %84 = bitcast {} addrspace(10)* %37 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)*, !dbg !11077
  %85 = addrspacecast { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* %84 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !11077
  %arraylen_ptr = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %85, i64 0, i32 1, !dbg !11077
  %arraylen = load i64, i64 addrspace(11)* %arraylen_ptr, align 8, !dbg !11077, !tbaa !262, !range !150, !alias.scope !265, !noalias !266
  %inbounds.not = icmp eq i64 %arraylen, 0, !dbg !11077
  br i1 %inbounds.not, label %oob, label %idxend, !dbg !11077

oob:                                              ; preds = %L32
  %errorbox = alloca i64, align 8, !dbg !11077
  store i64 1, i64* %errorbox, align 8, !dbg !11077, !noalias !11079
  %86 = addrspacecast {} addrspace(10)* %37 to {} addrspace(12)*, !dbg !11077
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %8) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %11) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %14) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %17) #143
  call void @ijl_bounds_error_ints({} addrspace(12)* %86, i64* noundef nonnull align 8 %errorbox, i64 noundef 1) #147, !dbg !11077
  unreachable, !dbg !11077

idxend:                                           ; preds = %L32
  %87 = bitcast {} addrspace(10)* %37 to double addrspace(13)* addrspace(10)*, !dbg !11077
  %88 = addrspacecast double addrspace(13)* addrspace(10)* %87 to double addrspace(13)* addrspace(11)*, !dbg !11077
  %arrayptr54107 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %88, align 8, !dbg !11077, !tbaa !298, !alias.scope !11080, !noalias !266, !nonnull !111
  %arrayref = load double, double addrspace(13)* %arrayptr54107, align 8, !dbg !11077, !tbaa !293, !alias.scope !170, !noalias !295
  %89 = bitcast {} addrspace(10)* %38 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)*, !dbg !11077
  %90 = addrspacecast { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* %89 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !11077
  %arraylen_ptr55 = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %90, i64 0, i32 1, !dbg !11077
  %arraylen56 = load i64, i64 addrspace(11)* %arraylen_ptr55, align 8, !dbg !11077, !tbaa !262, !range !150, !alias.scope !265, !noalias !266
  %inbounds57.not = icmp eq i64 %arraylen56, 0, !dbg !11077
  br i1 %inbounds57.not, label %oob58, label %idxend60, !dbg !11077

oob58:                                            ; preds = %idxend
  %errorbox59 = alloca i64, align 8, !dbg !11077
  store i64 1, i64* %errorbox59, align 8, !dbg !11077, !noalias !11079
  %91 = addrspacecast {} addrspace(10)* %38 to {} addrspace(12)*, !dbg !11077
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %8) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %11) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %14) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %17) #143
  call void @ijl_bounds_error_ints({} addrspace(12)* %91, i64* noundef nonnull align 8 %errorbox59, i64 noundef 1) #147, !dbg !11077
  unreachable, !dbg !11077

idxend60:                                         ; preds = %idxend
  %92 = bitcast {} addrspace(10)* %39 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)*, !dbg !11077
  %93 = addrspacecast { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* %92 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !11077
  %arraylen_ptr64 = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %93, i64 0, i32 1, !dbg !11077
  %arraylen65 = load i64, i64 addrspace(11)* %arraylen_ptr64, align 8, !dbg !11077, !tbaa !262, !range !150, !alias.scope !265, !noalias !266
  %inbounds66.not = icmp eq i64 %arraylen65, 0, !dbg !11077
  br i1 %inbounds66.not, label %oob67, label %idxend69, !dbg !11077

oob67:                                            ; preds = %idxend60
  %errorbox68 = alloca i64, align 8, !dbg !11077
  store i64 1, i64* %errorbox68, align 8, !dbg !11077, !noalias !11079
  %94 = addrspacecast {} addrspace(10)* %39 to {} addrspace(12)*, !dbg !11077
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %8) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %11) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %14) #143
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %17) #143
  call void @ijl_bounds_error_ints({} addrspace(12)* %94, i64* noundef nonnull align 8 %errorbox68, i64 noundef 1) #147, !dbg !11077
  unreachable, !dbg !11077

idxend69:                                         ; preds = %idxend60
  %95 = bitcast {} addrspace(10)* %38 to double addrspace(13)* addrspace(10)*, !dbg !11077
  %96 = addrspacecast double addrspace(13)* addrspace(10)* %95 to double addrspace(13)* addrspace(11)*, !dbg !11077
  %arrayptr62108 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %96, align 8, !dbg !11077, !tbaa !298, !alias.scope !11080, !noalias !266, !nonnull !111
  %arrayref63 = load double, double addrspace(13)* %arrayptr62108, align 8, !dbg !11077, !tbaa !293, !alias.scope !170, !noalias !295
  %97 = bitcast {} addrspace(10)* %39 to double addrspace(13)* addrspace(10)*, !dbg !11077
  %98 = addrspacecast double addrspace(13)* addrspace(10)* %97 to double addrspace(13)* addrspace(11)*, !dbg !11077
  %arrayptr71109 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %98, align 8, !dbg !11077, !tbaa !298, !alias.scope !11080, !noalias !266, !nonnull !111
  %arrayref72 = load double, double addrspace(13)* %arrayptr71109, align 8, !dbg !11077, !tbaa !293, !alias.scope !170, !noalias !295
  %newstruct73.sroa.0.0..sroa_idx = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0, !dbg !11078
  store double %arrayref, double* %newstruct73.sroa.0.0..sroa_idx, align 8, !dbg !11078, !noalias !11079
  %newstruct73.sroa.2.0..sroa_idx110 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1, !dbg !11078
  store double %arrayref63, double* %newstruct73.sroa.2.0..sroa_idx110, align 8, !dbg !11078, !noalias !11079
  %newstruct73.sroa.3.0..sroa_idx111 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2, !dbg !11078
  store double %arrayref72, double* %newstruct73.sroa.3.0..sroa_idx111, align 8, !dbg !11078, !noalias !11079
  ret void, !dbg !11078
}

Illegal replace ficticious phi for:   %unbox49.unpack101_replacementA = phi i64 , !dbg !192 of   %unbox49.unpack101 = load i64, i64 addrspace(11)* %unbox49.elt100, align 8, !dbg !218, !tbaa !117, !alias.scope !148, !noalias !151
; Function Attrs: mustprogress willreturn
define internal fastcc { double, double } @diffejulia_laic1__5971([3 x double]* noalias nocapture nofree writeonly sret([3 x double]) align 8 dereferenceable(24) "enzyme_sret" %0, [3 x double]* nocapture nofree align 8 "enzyme_sret" %"'", i64 signext "enzyme_inactive" %1, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* nocapture readonly align 8 dereferenceable(40) %2, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } addrspace(11)* nocapture align 8 %"'1", double %3, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* nocapture readonly align 8 dereferenceable(48) %4, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } addrspace(11)* nocapture align 8 %"'2", double %5, { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg) unnamed_addr #130 !dbg !17365 {
top:
  %"'mi" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 6
  %6 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 7
  %"'ipc" = bitcast i8* %"'mi" to i64*
  %7 = bitcast i8* %6 to i64*, !enzyme_caststack !111
  %"'ipc36" = bitcast i64* %"'ipc" to i8*
  %8 = bitcast i64* %7 to i8*
  %"'mi26" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 4
  %9 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 5
  %"'ipc37" = bitcast i8* %"'mi26" to i64*
  %10 = bitcast i8* %9 to i64*, !enzyme_caststack !111
  %"'ipc38" = bitcast i64* %"'ipc37" to i8*
  %11 = bitcast i64* %10 to i8*
  %"'mi25" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 2
  %12 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 3
  %"'ipc40" = bitcast i8* %"'mi25" to i64*
  %13 = bitcast i8* %12 to i64*, !enzyme_caststack !111
  %"'ipc41" = bitcast i64* %"'ipc40" to i8*
  %14 = bitcast i64* %13 to i8*
  %"'mi24" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 0
  %15 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 1
  %"'ipc44" = bitcast i8* %"'mi24" to i64*
  %16 = bitcast i8* %15 to i64*, !enzyme_caststack !111
  %"'ipc45" = bitcast i64* %"'ipc44" to i8*
  %17 = bitcast i64* %16 to i8*
  %18 = call {}*** @julia.get_pgcstack() #143
  %ptls_field75_replacementA = phi {}*** 
  %ptls_load7677_replacementA = phi i64** 
  %_replacementA20 = phi i64 addrspace(11)* , !dbg !17366
  %unbox_replacementA = phi i64 , !dbg !17375
  %unbox2 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 13, !dbg !17375
  %_replacementA19 = phi i64 , !dbg !17375
  %_replacementA18 = phi i64 , !dbg !17377
  %_replacementA17 = phi i64 , !dbg !17378
  %_replacementA16 = phi i64 addrspace(11)* , !dbg !17383
  %_replacementA15 = phi i64 addrspace(11)* , !dbg !17392
  %unbox3_replacementA = phi i64 , !dbg !17394
  %unbox4_replacementA = phi i64 , !dbg !17394
  %_replacementA14 = phi i64 , !dbg !17394
  %_replacementA13 = phi i64 , !dbg !17396
  %_replacementA = phi i64 , !dbg !17397
  %.not_replacementA = phi i1 , !dbg !17402
  br i1 true, label %L32, label %L20, !dbg !17391

L20:                                              ; preds = %top
  %_replacementA33 = phi {} addrspace(10)* , !dbg !17404
  %_replacementA32 = phi {} addrspace(10)* , !dbg !17404
  %_replacementA31 = phi {} addrspace(10)* , !dbg !17404
  %current_task978_replacementA = phi {}*** , !dbg !17404
  %current_task9_replacementA = phi {}** , !dbg !17404
  %box_replacementA = phi {} addrspace(10)* , !dbg !17404
  %_replacementA30 = phi [1 x {} addrspace(10)*] addrspace(10)* , !dbg !17404
  %_replacementA28 = phi {} addrspace(12)* , !dbg !17404
  unreachable

L32:                                              ; preds = %top
  %19 = call {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 1), !dbg !17405
  %20 = bitcast {} addrspace(10)* %19 to i8 addrspace(13)* addrspace(10)*, !dbg !17405
  %21 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(10)* %20, align 8, !dbg !17405
  call void @llvm.memset.p13i8.i64(i8 addrspace(13)* align 8 %21, i8 0, i64 8, i1 false), !dbg !17405
  %22 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !17405
  %23 = call {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 1), !dbg !17407
  %24 = bitcast {} addrspace(10)* %23 to i8 addrspace(13)* addrspace(10)*, !dbg !17407
  %25 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(10)* %24, align 8, !dbg !17407
  call void @llvm.memset.p13i8.i64(i8 addrspace(13)* align 8 %25, i8 0, i64 8, i1 false), !dbg !17407
  %26 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !17407
  %27 = call {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 1), !dbg !17409
  %28 = bitcast {} addrspace(10)* %27 to i8 addrspace(13)* addrspace(10)*, !dbg !17409
  %29 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(10)* %28, align 8, !dbg !17409
  call void @llvm.memset.p13i8.i64(i8 addrspace(13)* align 8 %29, i8 0, i64 8, i1 false), !dbg !17409
  %30 = call noalias nonnull {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 47648974261088 to {}*) to {} addrspace(10)*), i64 noundef 1) #144, !dbg !17409
  %"'ipc92" = bitcast i64* %"'ipc40" to double*, !dbg !17411
  %_replacementA93 = phi double* , !dbg !17411
  %"'ipc90" = bitcast i64* %"'ipc44" to double*, !dbg !17411
  %_replacementA91 = phi double* , !dbg !17411
  %getfield_addr_replacementA = phi {} addrspace(10)* addrspace(11)* , !dbg !17415
  %"getfield'il_phi" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 12, !dbg !17415
  %getfield_replacementA = phi {} addrspace(10)* , !dbg !17415
  %"'ipc87" = addrspacecast {} addrspace(10)* %"getfield'il_phi" to {} addrspace(11)*, !dbg !17417
  %_replacementA89 = phi {} addrspace(11)* , !dbg !17417
  %31 = call {}* @julia.pointer_from_objref({} addrspace(11)* %"'ipc87"), !dbg !17417
  %_replacementA88 = phi {}* , !dbg !17417
  %_replacementA86 = phi i8** , !dbg !17417
  %"arrayptr'il_phi" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 11, !dbg !17417
  %arrayptr_replacementA = phi i8* , !dbg !17417
  %32 = shl i64 %unbox2, 3, !dbg !17418
  %33 = add i64 %32, -8, !dbg !17418
  %"'ipg" = getelementptr i8, i8* %"arrayptr'il_phi", i64 %33, !dbg !17420
  %_replacementA85 = phi i8* , !dbg !17420
  %"'ipc39" = ptrtoint i8* %"'ipg" to i64, !dbg !17420
  %34 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 14, !dbg !17415
  %getfield_addr29_replacementA = phi {} addrspace(10)* addrspace(11)* , !dbg !17415
  %"getfield30'il_phi" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 10, !dbg !17415
  %getfield30_replacementA = phi {} addrspace(10)* , !dbg !17415
  %"'ipc82" = addrspacecast {} addrspace(10)* %"getfield30'il_phi" to {} addrspace(11)*, !dbg !17417
  %_replacementA84 = phi {} addrspace(11)* , !dbg !17417
  %35 = call {}* @julia.pointer_from_objref({} addrspace(11)* %"'ipc82"), !dbg !17417
  %_replacementA83 = phi {}* , !dbg !17417
  %_replacementA81 = phi i8** , !dbg !17417
  %"arrayptr32'il_phi" = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 9, !dbg !17417
  %arrayptr32_replacementA = phi i8* , !dbg !17417
  %_replacementA78 = phi {} addrspace(10)* addrspace(11)* , !dbg !17421
  %arraysize_ptr_replacementA = phi {} addrspace(10)* addrspace(11)* , !dbg !17421
  %_replacementA77 = phi i64 addrspace(11)* , !dbg !17421
  %arraysize_replacementA = phi i64 , !dbg !17421
  %unbox37_replacementA = phi i64 , !dbg !17425
  %_replacementA76 = phi i64 , !dbg !17425
  %_replacementA75 = phi i64 , !dbg !17430
  %_replacementA74 = phi i64 , !dbg !17431
  %36 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 15, !dbg !17418
  %37 = add i64 %36, -8, !dbg !17418
  %"'ipg42" = getelementptr i8, i8* %"arrayptr32'il_phi", i64 %37, !dbg !17420
  %_replacementA73 = phi i8* , !dbg !17420
  %"'ipc43" = ptrtoint i8* %"'ipg42" to i64, !dbg !17420
  %38 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 16, !dbg !17432
  %"'ipc72" = addrspacecast {} addrspace(10)* %19 to {} addrspace(11)*, !dbg !17432
  %39 = addrspacecast {} addrspace(10)* %22 to {} addrspace(11)*, !dbg !17432
  %40 = call {}* @julia.pointer_from_objref({} addrspace(11)* %"'ipc72"), !dbg !17432
  %41 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %39) #145, !dbg !17432
  %"'ipc71" = bitcast {}* %40 to i8**, !dbg !17432
  %42 = bitcast {}* %41 to i8**, !dbg !17432
  %"arrayptr43'ipl" = load i8*, i8** %"'ipc71", align 8, !dbg !17432, !tbaa !298, !alias.scope !17433, !noalias !17436, !nonnull !111
  %arrayptr43 = load i8*, i8** %42, align 8, !dbg !17432, !tbaa !298, !alias.scope !17438, !noalias !17439, !nonnull !111
  %"'ipc46" = ptrtoint i8* %"arrayptr43'ipl" to i64, !dbg !17432
  %43 = ptrtoint i8* %arrayptr43 to i64, !dbg !17432
  %"'ipc70" = addrspacecast {} addrspace(10)* %23 to {} addrspace(11)*, !dbg !17432
  %44 = addrspacecast {} addrspace(10)* %26 to {} addrspace(11)*, !dbg !17432
  %45 = call {}* @julia.pointer_from_objref({} addrspace(11)* %"'ipc70"), !dbg !17432
  %46 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %44) #145, !dbg !17432
  %"'ipc69" = bitcast {}* %45 to i8**, !dbg !17432
  %47 = bitcast {}* %46 to i8**, !dbg !17432
  %"arrayptr45'ipl" = load i8*, i8** %"'ipc69", align 8, !dbg !17432, !tbaa !298, !alias.scope !17440, !noalias !17443, !nonnull !111
  %arrayptr45 = load i8*, i8** %47, align 8, !dbg !17432, !tbaa !298, !alias.scope !17445, !noalias !17446, !nonnull !111
  %"'ipc47" = ptrtoint i8* %"arrayptr45'ipl" to i64, !dbg !17432
  %48 = ptrtoint i8* %arrayptr45 to i64, !dbg !17432
  %"'ipc68" = addrspacecast {} addrspace(10)* %27 to {} addrspace(11)*, !dbg !17432
  %49 = addrspacecast {} addrspace(10)* %30 to {} addrspace(11)*, !dbg !17432
  %50 = call {}* @julia.pointer_from_objref({} addrspace(11)* %"'ipc68"), !dbg !17432
  %51 = call nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %49) #145, !dbg !17432
  %"'ipc67" = bitcast {}* %50 to i8**, !dbg !17432
  %52 = bitcast {}* %51 to i8**, !dbg !17432
  %"arrayptr47'ipl" = load i8*, i8** %"'ipc67", align 8, !dbg !17432, !tbaa !298, !alias.scope !17447, !noalias !17450, !nonnull !111
  %arrayptr47 = load i8*, i8** %52, align 8, !dbg !17432, !tbaa !298, !alias.scope !17452, !noalias !17453, !nonnull !111
  %"'ipc48" = ptrtoint i8* %"arrayptr47'ipl" to i64, !dbg !17432
  %53 = ptrtoint i8* %arrayptr47 to i64, !dbg !17432
  %"'ipiv" = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } undef, {} addrspace(10)* %"getfield30'il_phi", 0, !dbg !17414
  %_replacementA66 = phi { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } , !dbg !17414
  %"'ipiv50" = insertvalue [2 x i64] undef, i64 %unbox4_replacementA, 0, !dbg !17414
  %_replacementA65 = phi [2 x i64] , !dbg !17414
  %"unbox48.unpack84.unpack95'ipiv" = insertvalue [2 x i64] %"'ipiv50", i64 %unbox3_replacementA, 1, !dbg !17414
  %unbox48.unpack84.unpack95_replacementA = phi [2 x i64] , !dbg !17414
  %"'ipiv51" = insertvalue { [2 x i64], i64 } undef, [2 x i64] %"unbox48.unpack84.unpack95'ipiv", 0, !dbg !17414
  %_replacementA64 = phi { [2 x i64], i64 } , !dbg !17414
  %"unbox48.unpack8492'ipiv" = insertvalue { [2 x i64], i64 } %"'ipiv51", i64 %unbox37_replacementA, 1, !dbg !17414
  %unbox48.unpack8492_replacementA = phi { [2 x i64], i64 } , !dbg !17414
  %"'ipiv52" = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %"'ipiv", { [2 x i64], i64 } %"unbox48.unpack8492'ipiv", 1, !dbg !17414
  %_replacementA63 = phi { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } , !dbg !17414
  %unbox48.elt85_replacementA = phi i64 addrspace(11)* , !dbg !17414
  %unbox48.unpack86_replacementA = phi i64 , !dbg !17414
  %"'ipiv53" = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %"'ipiv52", i64 %unbox48.unpack86_replacementA, 2, !dbg !17414
  %_replacementA62 = phi { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } , !dbg !17414
  %unbox48.elt87_replacementA = phi i64 addrspace(11)* , !dbg !17414
  %unbox48.unpack88_replacementA = phi i64 , !dbg !17414
  %"unbox4889'ipiv" = insertvalue { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %"'ipiv53", i64 %unbox48.unpack88_replacementA, 3, !dbg !17414
  %unbox4889 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 17, !dbg !17414
  %"'ipiv54" = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } undef, {} addrspace(10)* %"getfield'il_phi", 0, !dbg !17414
  %_replacementA61 = phi { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } , !dbg !17414
  %"'ipiv55" = insertvalue [2 x i64] undef, i64 %unbox2, 0, !dbg !17414
  %_replacementA60 = phi [2 x i64] , !dbg !17414
  %"unbox49.unpack97.unpack106'ipiv" = insertvalue [2 x i64] %"'ipiv55", i64 %unbox_replacementA, 1, !dbg !17414
  %unbox49.unpack97.unpack106_replacementA = phi [2 x i64] , !dbg !17414
  %"unbox49.unpack97103'ipiv" = insertvalue [1 x [2 x i64]] undef, [2 x i64] %"unbox49.unpack97.unpack106'ipiv", 0, !dbg !17414
  %unbox49.unpack97103_replacementA = phi [1 x [2 x i64]] , !dbg !17414
  %"'ipiv56" = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %"'ipiv54", [1 x [2 x i64]] %"unbox49.unpack97103'ipiv", 1, !dbg !17414
  %_replacementA59 = phi { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } , !dbg !17414
  %unbox49.elt98_replacementA = phi i64 addrspace(11)* , !dbg !17414
  %unbox49.unpack99_replacementA = phi i64 , !dbg !17414
  %"'ipiv57" = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %"'ipiv56", i64 %unbox49.unpack99_replacementA, 2, !dbg !17414
  %_replacementA58 = phi { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } , !dbg !17414
  %unbox49.elt100_replacementA = phi i64 addrspace(11)* , !dbg !17414
  %unbox49.unpack101_replacementA = phi i64 , !dbg !17414
  %"unbox49102'ipiv" = insertvalue { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %"'ipiv57", i64 %unbox49.unpack101_replacementA, 3, !dbg !17414
  %unbox49102 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 18, !dbg !17414
  %tapeArg49 = extractvalue { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i8*, {} addrspace(10)*, i64, i64, i64, i64, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 }, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } } %tapeArg, 8, !dbg !17414
  %_replacementA35 = phi { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* , !dbg !17454
  %_replacementA34 = phi { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* , !dbg !17454
  %arraylen_ptr_replacementA = phi i64 addrspace(11)* , !dbg !17454
  %arraylen_replacementA = phi i64 , !dbg !17454
  %inbounds.not_replacementA = phi i1 , !dbg !17454
  br i1 false, label %oob, label %idxend, !dbg !17454

oob:                                              ; preds = %L32
  %errorbox_replacementA = phi i64* , !dbg !17454
  unreachable

idxend:                                           ; preds = %L32
  %"'ipc97" = bitcast {} addrspace(10)* %19 to double addrspace(13)* addrspace(10)*, !dbg !17454
  %_replacementA100 = phi double addrspace(13)* addrspace(10)* , !dbg !17454
  %"'ipc98" = addrspacecast double addrspace(13)* addrspace(10)* %"'ipc97" to double addrspace(13)* addrspace(11)*, !dbg !17454
  %_replacementA99 = phi double addrspace(13)* addrspace(11)* , !dbg !17454
  %"arrayptr54107'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc98", align 8, !dbg !17454, !tbaa !298, !alias.scope !17456, !noalias !17436, !nonnull !111
  %arrayptr54107_replacementA = phi double addrspace(13)* , !dbg !17454
  %arrayref_replacementA = phi double , !dbg !17454
  %_replacementA96 = phi { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* , !dbg !17454
  %_replacementA95 = phi { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* , !dbg !17454
  %arraylen_ptr55_replacementA = phi i64 addrspace(11)* , !dbg !17454
  %arraylen56_replacementA = phi i64 , !dbg !17454
  %inbounds57.not_replacementA = phi i1 , !dbg !17454
  br i1 false, label %oob58, label %idxend60, !dbg !17454

oob58:                                            ; preds = %idxend
  %errorbox59_replacementA = phi i64* , !dbg !17454
  unreachable

idxend60:                                         ; preds = %idxend
  %arraylen_ptr64_replacementA = phi i64 addrspace(11)* , !dbg !17454
  %inbounds66.not_replacementA = phi i1 , !dbg !17454
  br i1 false, label %oob67, label %idxend69, !dbg !17454

oob67:                                            ; preds = %idxend60
  %errorbox68_replacementA = phi i64* , !dbg !17454
  %_replacementA104 = phi {} addrspace(12)* , !dbg !17454
  unreachable

idxend69:                                         ; preds = %idxend60
  %"'ipc109" = bitcast {} addrspace(10)* %23 to double addrspace(13)* addrspace(10)*, !dbg !17454
  %_replacementA112 = phi double addrspace(13)* addrspace(10)* , !dbg !17454
  %"'ipc110" = addrspacecast double addrspace(13)* addrspace(10)* %"'ipc109" to double addrspace(13)* addrspace(11)*, !dbg !17454
  %_replacementA111 = phi double addrspace(13)* addrspace(11)* , !dbg !17454
  %"arrayptr62108'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc110", align 8, !dbg !17454, !tbaa !298, !alias.scope !17457, !noalias !17443, !nonnull !111
  %arrayptr62108_replacementA = phi double addrspace(13)* , !dbg !17454
  %arrayref63_replacementA = phi double , !dbg !17454
  %"'ipc105" = bitcast {} addrspace(10)* %27 to double addrspace(13)* addrspace(10)*, !dbg !17454
  %"'ipc106" = addrspacecast double addrspace(13)* addrspace(10)* %"'ipc105" to double addrspace(13)* addrspace(11)*, !dbg !17454
  %_replacementA107 = phi double addrspace(13)* addrspace(11)* , !dbg !17454
  %"arrayptr71109'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc106", align 8, !dbg !17454, !tbaa !298, !alias.scope !17458, !noalias !17450, !nonnull !111
  %arrayref72_replacementA = phi double , !dbg !17454
  %"newstruct73.sroa.0.0..sroa_idx'ipg" = getelementptr inbounds [3 x double], [3 x double]* %"'", i64 0, i64 0, !dbg !17455
  %newstruct73.sroa.0.0..sroa_idx_replacementA = phi double* , !dbg !17455
  %"newstruct73.sroa.2.0..sroa_idx110'ipg" = getelementptr inbounds [3 x double], [3 x double]* %"'", i64 0, i64 1, !dbg !17455
  %newstruct73.sroa.2.0..sroa_idx110_replacementA = phi double* , !dbg !17455
  %"newstruct73.sroa.3.0..sroa_idx111'ipg" = getelementptr inbounds [3 x double], [3 x double]* %"'", i64 0, i64 2, !dbg !17455
  %newstruct73.sroa.3.0..sroa_idx111_replacementA = phi double* , !dbg !17455
  br label %invertidxend69, !dbg !17455

allocsForInversion:                               ; No predecessors!
  %"'de" = alloca double, align 8
  %54 = getelementptr double, double* %"'de", i64 0
  store double 0.000000e+00, double* %54, align 8
  %"'de27" = alloca double, align 8
  %55 = getelementptr double, double* %"'de27", i64 0
  store double 0.000000e+00, double* %55, align 8
  %"arrayref'de" = alloca double, align 8
  %56 = getelementptr double, double* %"arrayref'de", i64 0
  store double 0.000000e+00, double* %56, align 8
  %"arrayref72'de" = alloca double, align 8
  %57 = getelementptr double, double* %"arrayref72'de", i64 0
  store double 0.000000e+00, double* %57, align 8
  %"arrayref63'de" = alloca double, align 8
  %58 = getelementptr double, double* %"arrayref63'de", i64 0
  store double 0.000000e+00, double* %58, align 8

inverttop:                                        ; preds = %invertL32
  fence syncscope("singlethread") seq_cst
  fence syncscope("singlethread") seq_cst
  call void @free(i8* nonnull %"'mi24")
  call void @free(i8* %15)
  call void @free(i8* nonnull %"'mi25")
  call void @free(i8* %12)
  call void @free(i8* nonnull %"'mi26")
  call void @free(i8* %9)
  call void @free(i8* nonnull %"'mi")
  call void @free(i8* %6)
  %59 = load double, double* %"'de", align 8
  %60 = load double, double* %"'de27", align 8
  %61 = insertvalue { double, double } undef, double %59, 0
  %62 = insertvalue { double, double } %61, double %60, 1
  ret { double, double } %62

invertL20:                                        ; No predecessors!

invertL32:                                        ; preds = %invertidxend
  call void inttoptr (i64 47653617007840 to void (i8*)*)(i8* getelementptr inbounds ([21983 x i8], [21983 x i8]* @61, i32 0, i32 0)) #146, !dbg !17414
  call void @diffedlaic1_64_(i8* %8, i8* %"'ipc36", i8* %11, i8* %"'ipc38", i64 %34, i64 %"'ipc39", i8* %14, i8* %"'ipc41", i64 %38, i64 %"'ipc43", i8* %17, i8* %"'ipc45", i64 %43, i64 %"'ipc46", i64 %48, i64 %"'ipc47", i64 %53, i64 %"'ipc48", {} addrspace(10)* %tapeArg49) [ "jl_roots"({} addrspace(10)* %30, {} addrspace(10)* %27, {} addrspace(10)* %26, {} addrspace(10)* %23, {} addrspace(10)* %22, {} addrspace(10)* %19, {} addrspace(10)* null, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %unbox4889, { {} addrspace(10)*, { [2 x i64], i64 }, i64, i64 } %"unbox4889'ipiv", {} addrspace(10)* null, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %unbox49102, { {} addrspace(10)*, [1 x [2 x i64]], i64, i64 } %"unbox49102'ipiv", {} addrspace(10)* null, {} addrspace(10)* null) ], !dbg !17414
  %63 = load double, double* %"'ipc90", align 16, !dbg !17411, !tbaa !1546, !alias.scope !17459, !noalias !17462
  store double 0.000000e+00, double* %"'ipc90", align 16, !dbg !17411, !tbaa !1546, !alias.scope !17459, !noalias !17462
  %64 = load double, double* %"'de27", align 8, !dbg !17411
  %65 = fadd fast double %64, %63, !dbg !17411
  store double %65, double* %"'de27", align 8, !dbg !17411
  %66 = load double, double* %"'ipc92", align 16, !dbg !17411, !tbaa !1546, !alias.scope !17464, !noalias !17467
  store double 0.000000e+00, double* %"'ipc92", align 16, !dbg !17411, !tbaa !1546, !alias.scope !17464, !noalias !17467
  %67 = load double, double* %"'de", align 8, !dbg !17411
  %68 = fadd fast double %67, %66, !dbg !17411
  store double %68, double* %"'de", align 8, !dbg !17411
  br label %inverttop

invertoob:                                        ; No predecessors!

invertidxend:                                     ; preds = %invertidxend60
  %69 = load double, double* %"arrayref'de", align 8, !dbg !17454
  store double 0.000000e+00, double* %"arrayref'de", align 8, !dbg !17454
  %70 = load double, double addrspace(13)* %"arrayptr54107'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17469, !noalias !17472
  %71 = fadd fast double %70, %69, !dbg !17454
  store double %71, double addrspace(13)* %"arrayptr54107'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17469, !noalias !17472
  br label %invertL32

invertoob58:                                      ; No predecessors!

invertidxend60:                                   ; preds = %invertidxend69
  br label %invertidxend

invertoob67:                                      ; No predecessors!

invertidxend69:                                   ; preds = %idxend69
  %72 = load double, double* %"newstruct73.sroa.3.0..sroa_idx111'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  store double 0.000000e+00, double* %"newstruct73.sroa.3.0..sroa_idx111'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  %73 = load double, double* %"arrayref72'de", align 8, !dbg !17455
  %74 = fadd fast double %73, %72, !dbg !17455
  store double %74, double* %"arrayref72'de", align 8, !dbg !17455
  %75 = load double, double* %"newstruct73.sroa.2.0..sroa_idx110'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  store double 0.000000e+00, double* %"newstruct73.sroa.2.0..sroa_idx110'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  %76 = load double, double* %"arrayref63'de", align 8, !dbg !17455
  %77 = fadd fast double %76, %75, !dbg !17455
  store double %77, double* %"arrayref63'de", align 8, !dbg !17455
  %78 = load double, double* %"newstruct73.sroa.0.0..sroa_idx'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  store double 0.000000e+00, double* %"newstruct73.sroa.0.0..sroa_idx'ipg", align 8, !dbg !17455, !alias.scope !17474, !noalias !17477
  %79 = load double, double* %"arrayref'de", align 8, !dbg !17455
  %80 = fadd fast double %79, %78, !dbg !17455
  store double %80, double* %"arrayref'de", align 8, !dbg !17455
  %81 = load double, double* %"arrayref72'de", align 8, !dbg !17454
  store double 0.000000e+00, double* %"arrayref72'de", align 8, !dbg !17454
  %82 = load double, double addrspace(13)* %"arrayptr71109'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17479, !noalias !17482
  %83 = fadd fast double %82, %81, !dbg !17454
  store double %83, double addrspace(13)* %"arrayptr71109'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17479, !noalias !17482
  %84 = load double, double* %"arrayref63'de", align 8, !dbg !17454
  store double 0.000000e+00, double* %"arrayref63'de", align 8, !dbg !17454
  %85 = load double, double addrspace(13)* %"arrayptr62108'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17484, !noalias !17487
  %86 = fadd fast double %85, %84, !dbg !17454
  store double %86, double addrspace(13)* %"arrayptr62108'ipl", align 8, !dbg !17454, !tbaa !293, !alias.scope !17484, !noalias !17487
  br label %invertidxend60
}

LLVM.LoadInst(%unbox49.unpack101 = load i64, i64 addrspace(11)* %unbox49.elt100, align 8, !dbg !218, !tbaa !117, !alias.scope !148, !noalias !151)
LLVM.PHIInst(%unbox49.unpack101_replacementA = phi i64 , !dbg !192)

Stacktrace:
 [1] laic1!
   @ ~/modules/julia/1.10.0/julia-1.10.0-rc1/share/julia/stdlib/v1.10/LinearAlgebra/src/lapack.jl:2522

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/rbuCz/src/compiler.jl:5902
  [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/rbuCz/src/api.jl:141
  [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::NTuple{5, Bool}, returnPrimal::Bool, jlrules::Vector{String}, expectedTapeType::Type, loweredArgs::Set{Int64}, boxedArgs::Set{Int64})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:7726
  [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/rbuCz/src/compiler.jl:9278
  [5] codegen
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:8886 [inlined]
  [6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool) (repeats 2 times)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9830
  [7] cached_compilation
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9864 [inlined]
  [8] (::Enzyme.Compiler.var"#474#475"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, NTuple{5, Bool}, Int64, Bool, Bool, UInt64, DataType})(ctx::LLVM.Context)
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9921
  [9] JuliaContext(f::Enzyme.Compiler.var"#474#475"{DataType, DataType, DataType, Enzyme.API.CDerivativeMode, NTuple{5, Bool}, Int64, Bool, Bool, UInt64, DataType})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/driver.jl:47
 [10] #s325#473
    @ ~/.julia/packages/Enzyme/rbuCz/src/compiler.jl:9882 [inlined]
 [11] var"#s325#473"(FA::Any, A::Any, TT::Any, Mode::Any, ModifiedBetween::Any, width::Any, ReturnPrimal::Any, ShadowInit::Any, World::Any, ABI::Any, ::Any, ::Type, ::Type, ::Type, tt::Any, ::Type, ::Type, ::Type, ::Type, ::Type, ::Any)
    @ Enzyme.Compiler ./none:0
 [12] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:600
 [13] autodiff(::ReverseMode{false, FFIABI}, ::Const{typeof(cart2bary_enzyme)}, ::Type{Const{Nothing}}, ::Const{Matrix{Float64}}, ::Vararg{Any})
    @ Enzyme ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:207
 [14] autodiff(::ReverseMode{false, FFIABI}, ::Const{typeof(cart2bary_enzyme)}, ::Const{Matrix{Float64}}, ::Const{Matrix{Int64}}, ::Vararg{Any})
    @ Enzyme ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:236
 [15] autodiff
    @ ~/.julia/packages/Enzyme/rbuCz/src/Enzyme.jl:222 [inlined]
 [16] main()
    @ Main /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:66
 [17] top-level scope
    @ /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:72
in expression starting at /scratch/raayaiardakani.m/Redbird.jl/test/diff/test_cart2bary.jl:72
wsmoses commented 11 months ago

@matinraayai is this fixed. I cannot reproduce as your package requires a matlab install I don't have

wsmoses commented 6 months ago

@matinraayai as this doesn't have a reproducer I can check against am going to close as stale.

Please reopen if it persists.