@@ -32,6 +32,8 @@ import Enzyme:
3232 add_edge!
3333using Enzyme
3434
35+ import Enzyme: OpaquePointerError
36+
3537import EnzymeCore
3638import EnzymeCore: EnzymeRules, ABI, FFIABI, DefaultABI
3739
@@ -3779,7 +3781,13 @@ function lower_convention(
37793781 push! (wrapper_types, typ)
37803782 push! (wrapper_attrs, LLVM. Attribute[EnumAttribute (" noalias" )])
37813783 else
3782- push! (wrapper_types, eltype (typ))
3784+
3785+ elty = convert (LLVMType, arg. typ)
3786+ if ! LLVM. is_opaque (typ)
3787+ @assert elty == eltype (typ)
3788+ end
3789+
3790+ push! (wrapper_types, elty)
37833791 push! (wrapper_attrs, LLVM. Attribute[])
37843792 push! (loweredArgs, arg. arg_i)
37853793 end
@@ -3941,7 +3949,13 @@ function lower_convention(
39413949 ),
39423950 )
39433951 end
3944- ptr = alloca! (builder, eltype (ty), LLVM. name (parm) * " .innerparm" )
3952+
3953+ elty = convert (LLVMType, arg. typ)
3954+ if ! LLVM. is_opaque (ty)
3955+ @assert elty == eltype (ty)
3956+ end
3957+
3958+ ptr = alloca! (builder, elty, LLVM. name (parm) * " .innerparm" )
39453959 if TT != = nothing && TT. parameters[arg. arg_i] <: Const
39463960 metadata (ptr)[" enzyme_inactive" ] = MDNode (LLVM. Metadata[])
39473961 end
0 commit comments