Hi All,
I am struggling to get precompilation working with Enzyme.jl. My package works fine without any precompile statements at the top level. But if I add some package function calls within my top-level module, I get some errors printed and a long stack trace during precompilation. Apologies for no MWE, but I was hoping that someone would just recognise this error:
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 2' from globals with 'i32 4' from start)
ERROR: LoadError: AssertionError: Could not statically ahead-of-time determine allocation element type of %8 = call noalias nonnull align 8 dereferenceable(16) "enzyme_type"="{[-1]:Pointer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef null, i64 %arraylen) #82, !dbg !164
Stacktrace:
[1] array_shadow_handler(B::Ptr{LLVM.API.LLVMOpaqueBuilder}, OrigCI::Ptr{LLVM.API.LLVMOpaqueValue}, numArgs::UInt64, Args::Ptr{Ptr{LLVM.API.LLVMOpaqueValue}}, gutils::Ptr{Nothing})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/3VNOP/src/rules/allocrules.jl:16
[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, runtimeActivity::Bool, width::Int64, additionalArg::Ptr{Nothing}, forceAnonymousTape::Bool, typeInfo::Enzyme.FnTypeInfo, uncacheable_args::Vector{Bool}, augmented::Ptr{Nothing}, atomicAdd::Bool)
@ Enzyme.API ~/.julia/packages/Enzyme/3VNOP/src/api.jl:269
[3] enzyme!(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, mod::LLVM.Module, primalf::LLVM.Function, TT::Type, mode::Enzyme.API.CDerivativeMode, width::Int64, parallel::Bool, actualRetType::Type, wrap::Bool, modifiedBetween::Tuple{Vararg{Bool, N}} where N, returnPrimal::Bool, expectedTapeType::Type, loweredArgs::Set{Int64}, boxedArgs::Set{Int64})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:1754
[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/3VNOP/src/compiler.jl:4664
[5] codegen
@ ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:3450 [inlined]
[6] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams}, postopt::Bool)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:5528
[7] _thunk
@ ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:5528 [inlined]
[8] cached_compilation
@ ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:5580 [inlined]
[9] thunkbase(mi::Core.MethodInstance, World::UInt64, FA::Type{<:EnzymeCore.Annotation}, A::Type{<:EnzymeCore.Annotation}, TT::Type, Mode::Enzyme.API.CDerivativeMode, width::Int64, ModifiedBetween::Tuple{Vararg{Bool, N}} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, edges::Vector{Any})
@ Enzyme.Compiler ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:5691
[10] thunk_generator(world::UInt64, source::LineNumberNode, FA::Type, A::Type, TT::Type, Mode::Enzyme.API.CDerivativeMode, Width::Int64, ModifiedBetween::Tuple{Vararg{Bool, N}} where N, ReturnPrimal::Bool, ShadowInit::Bool, ABI::Type, ErrIfFuncWritten::Bool, RuntimeActivity::Bool, self::Any, fakeworld::Any, fa::Type, a::Type, tt::Type, mode::Type, width::Type, modifiedbetween::Type, returnprimal::Type, shadowinit::Type, abi::Type, erriffuncwritten::Type, runtimeactivity::Type)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/3VNOP/src/compiler.jl:5876
[11] autodiff
There is more than that.