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

LLVM Assertion Error (on 1.10 and 1.11) #57245

Open
wsmoses opened this issue Feb 3, 2025 · 3 comments
Open

LLVM Assertion Error (on 1.10 and 1.11) #57245

wsmoses opened this issue Feb 3, 2025 · 3 comments

Comments

@wsmoses
Copy link
Contributor

wsmoses commented Feb 3, 2025

julia-debug: /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/Instructions.cpp:2560: void llvm::InsertValueInst::init(llvm::Value*, llvm::Value*, llvm::ArrayRef<unsigned int>, const llvm::Twine&): Assertion `ExtractValueInst::getIndexedType(Agg->getType(), Idxs) == Val->getType() && "Inserted value must match indexed type!"' failed.

[556648] signal (6.-6): Aborted
in expression starting at /home/wmoses/git/Reactant.jl/ext/ReactantCUDAExt.jl:937
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7715fca2881a)
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
init at /home/wmoses/git/Enzyme.jl/julia10/deps/srccache/llvm-julia-15.0.7-10/llvm/lib/IR/Instructions.cpp:2560
InsertValueInst at /home/wmoses/git/Enzyme.jl/julia10/usr/include/llvm/IR/Instructions.h:2640
Create at /home/wmoses/git/Enzyme.jl/julia10/usr/include/llvm/IR/Instructions.h:2565
CreateInsertValue at /home/wmoses/git/Enzyme.jl/julia10/usr/include/llvm/IR/IRBuilder.h:2343
emit_new_struct at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:4008
emit_builtin_call at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:3419
emit_call at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:4596
emit_expr at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:5512
emit_ssaval_assign at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:5101
emit_stmtpos at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:5335
emit_function at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:8382
jl_emit_code at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:8717
jl_emit_codeinst at /home/wmoses/git/Enzyme.jl/julia10/src/codegen.cpp:8791
_jl_compile_codeinst at /home/wmoses/git/Enzyme.jl/julia10/src/jitlayers.cpp:221
jl_generate_fptr_impl at /home/wmoses/git/Enzyme.jl/julia10/src/jitlayers.cpp:528
jl_compile_method_internal at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2481
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2887
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
adapt_storage at /home/wmoses/git/Reactant.jl/ext/ReactantCUDAExt.jl:347
adapt_structure at /home/wmoses/.julia/packages/Adapt/VO8tI/src/Adapt.jl:57 [inlined]
adapt at /home/wmoses/.julia/packages/Adapt/VO8tI/src/Adapt.jl:40 [inlined]

Trying to get more info via rr/gdb

@wsmoses
Copy link
Contributor Author

wsmoses commented Feb 3, 2025

#11 0x00007715fa65ff9b in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:4008
4008	                        strct = ctx.builder.CreateInsertValue(strct, fval, makeArrayRef(llvm_idx));
(rr) p strct->dump()
p fval{ i8 addrspace(1)*, {} addrspace(10)* } zeroinitializer
$1 = void
(rr) p fval->dump()
  %bitcast_coercion = bitcast {}* %48 to i8*, !dbg !95
$2 = void
(rr) p llvm_idx
$3 = 0

@wsmoses
Copy link
Contributor Author

wsmoses commented Feb 3, 2025

Old value = (llvm::Value *) 0x0
New value = (llvm::Value *) 0x560ffc92c1f0
0x00007715fa65fdcf in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:3996
3996	                        fval = emit_unbox(ctx, fty, fval_info, jtype);
(rr) p fval->dump()
  %bitcast_coercion = bitcast {}* %48 to i8*, !dbg !95
$6 = void
(rr) p jl_(jtype)
Core.LLVMPtr{Float64, 1}
$7 = void
(rr) p fval_info
$8 = {V = 0x560ffc92c1f0, Vboxed = 0x0, TIndex = 0x0, constant = 0x0, typ = 0x7715f2511590, isboxed = false, isghost = false, tbaa = 0x0, 
  promotion_point = 0x0, promotion_ssa = -1}
(rr) p fty
$9 = (llvm::Type *) 0x560ffd95d6d0
(rr) p fty->dump()
i8 addrspace(1)*
$10 = void

Looks like something doesn't respect address spaces

@wsmoses
Copy link
Contributor Author

wsmoses commented Feb 3, 2025

0x00007715fa65fdcf in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:3996
3996	                        fval = emit_unbox(ctx, fty, fval_info, jtype);
(rr) p fval->dump()
  %bitcast_coercion = bitcast {}* %48 to i8*, !dbg !95
$6 = void
(rr) p jl_(jtype)
Core.LLVMPtr{Float64, 1}
$7 = void
(rr) p fval_info
$8 = {V = 0x560ffc92c1f0, Vboxed = 0x0, TIndex = 0x0, constant = 0x0, typ = 0x7715f2511590, isboxed = false, isghost = false, tbaa = 0x0, 
  promotion_point = 0x0, promotion_ssa = -1}
(rr) p fty
$9 = (llvm::Type *) 0x560ffd95d6d0
(rr) p fty->dump()
i8 addrspace(1)*
$10 = void
(rr) reverse-next

Thread 1 hit Hardware watchpoint 1: fval

Old value = (llvm::Value *) 0x560ffc92c1f0
New value = (llvm::Value *) 0x0
0x00007715fa65fdc8 in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:3996
3996	                        fval = emit_unbox(ctx, fty, fval_info, jtype);
(rr) s

Thread 1 hit Hardware watchpoint 1: fval

Old value = (llvm::Value *) 0x0
New value = (llvm::Value *) 0x560ffc92c1f0
0x00007715fa65fdcf in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:3996
3996	                        fval = emit_unbox(ctx, fty, fval_info, jtype);
(rr) s
4001	                if (init_as_value) {
(rr) b emit_unbox
rc
Breakpoint 2 at 0x7715fa676931: file /home/wmoses/git/Enzyme.jl/julia10/src/intrinsics.cpp, line 435.
(rr) rc
Continuing.

Thread 1 hit Hardware watchpoint 1: fval

Old value = (llvm::Value *) 0x560ffc92c1f0
New value = (llvm::Value *) 0x0
0x00007715fa65fdc8 in emit_new_struct (ctx=..., ty=0x771554519890, nargs=2, argv=0x561000cb0948, is_promotable=true)
    at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:3996
3996	                        fval = emit_unbox(ctx, fty, fval_info, jtype);
(rr) rc
Continuing.

Thread 1 hit Breakpoint 2, emit_unbox (ctx=..., to=0x560ffd95d6d0, x=..., jt=0x7715f2511590) at /home/wmoses/git/Enzyme.jl/julia10/src/intrinsics.cpp:435
435	    assert(to != getVoidTy(ctx.builder.getContext()));
(rr) n
437	    if (x.isghost) {
(rr) 
448	    Constant *c = x.constant ? julia_const_to_llvm(ctx, x.constant) : NULL;
(rr) p x.constant
^CQuit
(rr) n
449	    if (!x.ispointer() || c) { // already unboxed, but sometimes need conversion
(rr) 
450	        Value *unboxed = c ? c : x.V;
(rr) 
451	        return emit_unboxed_coercion(ctx, to, unboxed);
(rr) p unboxed
$11 = (llvm::Value *) 0x560ffc92c1f0
(rr) p unboxed->dump()
  %bitcast_coercion = bitcast {}* %48 to i8*, !dbg !95
$12 = void
(rr) p to
$13 = (llvm::Type *) 0x560ffd95d6d0
(rr) p to->dump()
i8 addrspace(1)*
$14 = void
(rr) s
emit_unboxed_coercion (ctx=..., to=0x560ffd95d6d0, unboxed=0x560ffc92c1f0) at /home/wmoses/git/Enzyme.jl/julia10/src/intrinsics.cpp:386
386	    if (unboxed->getType() == to)
(rr) n
388	    if (CastInst::castIsValid(Instruction::Trunc, unboxed, to))
(rr) n
390	    unboxed = zext_struct(ctx, unboxed);
(rr) 
391	    Type *ty = unboxed->getType();
(rr) 
392	    if (ty == to)
(rr) 
394	    bool frompointer = ty->isPointerTy();
(rr) 
395	    bool topointer = to->isPointerTy();
(rr) 
396	    const DataLayout &DL = jl_Module->getDataLayout();
(rr) n
397	    if (ty->isVoidTy() || DL.getTypeSizeInBits(ty) != DL.getTypeSizeInBits(to)) {
(rr) 
402	    if (frompointer && topointer) {
(rr) 
403	        unboxed = emit_bitcast(ctx, unboxed, to);
(rr) p to->dump()
i8 addrspace(1)*
$15 = void
(rr) s
emit_bitcast (ctx=..., v=0x560ffc92c1f0, jl_value=0x560ffd95d6d0) at /home/wmoses/git/Enzyme.jl/julia10/src/cgutils.cpp:565
565	    if (isa<PointerType>(jl_value) &&
(rr) n
566	        v->getType()->getPointerAddressSpace() != jl_value->getPointerAddressSpace()) {
(rr) n
565	    if (isa<PointerType>(jl_value) &&
(rr) 
568	        Type *jl_value_addr = PointerType::getWithSamePointeeType(cast<PointerType>(jl_value), v->getType()->getPointerAddressSpace());
(rr) 
569	        ++EmittedPointerBitcast;
(rr) 
570	        return ctx.builder.CreateBitCast(v, jl_value_addr);
(rr) 

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

1 participant