-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
Here's a failing MWE from #2309
using Enzyme
a(x::Vector{Float64}, y::Float64) = sum(abs2, x) * y
b(x::Vector{Float64}, y::Float64) = sum(x) * abs2(y)
struct MyMixedStruct
bar::Float64
foo::Vector{Float64}
end
f6(x, y) = MyMixedStruct(a(x, y), [b(x, y)])
x = [1.0, 2.0, 3.0]
y = 4.0
z = f6(x, y)
das = (5.0, 11.0)
dbs = (7.0, 13.0)
dzs6 = (MyMixedStruct(das[1], [dbs[1]]), MyMixedStruct(das[2], [dbs[2]]))
f_annot = Const(f6)
x_and_dxs = BatchDuplicated(x, ntuple(_ -> make_zero(x), Val(2)))
y_and_dys = Active(y)
RA = Enzyme.guess_activity(typeof(z), Reverse)
# errors with "Stored value type does not match pointer operand type!"
forward, reverse = autodiff_thunk(ReverseSplitNoPrimal, typeof(f_annot), RA, typeof(x_and_dxs), typeof(y_and_dys))
Stack trace:
julia> forward, reverse = autodiff_thunk(ReverseSplitNoPrimal, typeof(f_annot), RA, typeof(x_and_dxs), typeof(y_and_dys))
Stored value type does not match pointer operand type!
store [2 x { double, {} addrspace(10)* }] %102, { double, {} addrspace(10)* }* %103, align 8, !dbg !1119
[2 x { double, {} addrspace(10)* }]; Function Attrs: mustprogress nofree willreturn
define "enzyme_type"="{[0]:Float@double, [8]:Pointer, [8,0]:Pointer, [8,0,-1]:Float@double, [8,8]:Pointer, [8,8,0]:Integer, [8,8,1]:Integer, [8,8,2]:Integer, [8,8,3]:Integer, [8,8,4]:Integer, [8,8,5]:Integer, [8,8,6]:Integer, [8,8,7]:Integer, [8,8,8]:Pointer, [8,8,8,-1]:Float@double, [8,16]:Integer, [8,17]:Integer, [8,18]:Integer, [8,19]:Integer, [8,20]:Integer, [8,21]:Integer, [8,22]:Integer, [8,23]:Integer}" "enzymejl_parmtype"="6325432592" "enzymejl_parmtype_ref"="1" { double, {} addrspace(10)* } @preprocess_julia_f6_15131_inner.3({} addrspace(10)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(24) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Pointer, [-1,8,0]:Integer, [-1,8,1]:Integer, [-1,8,2]:Integer, [-1,8,3]:Integer, [-1,8,4]:Integer, [-1,8,5]:Integer, [-1,8,6]:Integer, [-1,8,7]:Integer, [-1,8,8]:Pointer, [-1,8,8,-1]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer}" "enzymejl_parmtype"="4727291376" "enzymejl_parmtype_ref"="2" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="4781330384" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #10 !dbg !371 {
entry:
%pgcstack.i = call {}*** @julia.get_pgcstack() #18, !noalias !372
%ptls_field.i16 = getelementptr inbounds {}**, {}*** %pgcstack.i, i64 2
%2 = bitcast {}*** %ptls_field.i16 to i64***
%ptls_load.i1718 = load i64**, i64*** %2, align 8, !tbaa !13, !noalias !372
%3 = getelementptr inbounds i64*, i64** %ptls_load.i1718, i64 2
%safepoint.i = load i64*, i64** %3, align 8, !tbaa !17, !noalias !372
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint.i) #18, !dbg !376, !noalias !372
fence syncscope("singlethread") seq_cst
%4 = call fastcc double @julia__mapreduce_15181({} addrspace(10)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(24) %0) #19, !dbg !378, !noalias !372
%5 = bitcast {} addrspace(10)* %0 to i8 addrspace(10)*, !dbg !387
%6 = addrspacecast i8 addrspace(10)* %5 to i8 addrspace(11)*, !dbg !387
%7 = getelementptr inbounds i8, i8 addrspace(11)* %6, i64 16, !dbg !387
%8 = bitcast i8 addrspace(11)* %7 to i64 addrspace(11)*, !dbg !387
%9 = load i64, i64 addrspace(11)* %8, align 8, !dbg !387, !tbaa !30, !alias.scope !33, !noalias !401, !enzyme_type !41, !enzymejl_source_type_Int64 !0, !enzymejl_byref_BITS_VALUE !0, !enzyme_inactive !0
switch i64 %9, label %L34.i [
i64 0, label %julia_f6_15131_inner.exit
i64 1, label %L15.i
], !dbg !402
...
L99.i: ; preds = %L34.i
%_augmented35 = call fastcc { {} addrspace(10)*, double } @augmented_julia_mapreduce_impl_20764({} addrspace(10)* nocapture nofree readonly align 8 %0, [2 x {} addrspace(10)*] %"'", i64 signext 1, i64 signext %23), !dbg !1076
%subcache36 = extractvalue { {} addrspace(10)*, double } %_augmented35, 0, !dbg !1076
%68 = getelementptr inbounds { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }* %3, i32 0, i32 2, !dbg !1076
store {} addrspace(10)* %subcache36, {} addrspace(10)** %68, align 8, !dbg !1076
%69 = extractvalue { {} addrspace(10)*, double } %_augmented35, 1, !dbg !1076
br label %julia_f6_20735_inner.exit, !dbg !1078
julia_f6_20735_inner.exit.loopexit: ; preds = %L77.i
br label %julia_f6_20735_inner.exit, !dbg !1079
julia_f6_20735_inner.exit: ; preds = %julia_f6_20735_inner.exit.loopexit, %L99.i, %L36.i, %L15.i, %entry
%value_phi.i = phi double [ %39, %L15.i ], [ %69, %L99.i ], [ 0.000000e+00, %entry ], [ %60, %L36.i ], [ %67, %julia_f6_20735_inner.exit.loopexit ]
%70 = getelementptr inbounds { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }* %3, i32 0, i32 5
store double %value_phi.i, double* %70, align 8
%current_task1.i15 = getelementptr inbounds {}**, {}*** %pgcstack.i, i64 -14
%71 = fmul double %1, %1, !dbg !1080
%72 = fmul double %71, %value_phi.i, !dbg !1082
%73 = call {} addrspace(10)* @jl_alloc_genericmemory({} addrspace(10)* addrspacecast ({}* inttoptr (i64 4727291568 to {}*) to {} addrspace(10)*), i64 1), !dbg !1083
%74 = bitcast {} addrspace(10)* %73 to <{ i64, i8* }> addrspace(10)*, !dbg !1083
%75 = getelementptr inbounds <{ i64, i8* }>, <{ i64, i8* }> addrspace(10)* %74, i32 0, i32 1, !dbg !1083
%76 = load i8*, i8* addrspace(10)* %75, align 8, !dbg !1083
call void @llvm.memset.p0i8.i64(i8* align 8 %76, i8 0, i64 8, i1 false), !dbg !1083
%77 = insertvalue [2 x {} addrspace(10)*] undef, {} addrspace(10)* %73, 0, !dbg !1083
%78 = call {} addrspace(10)* @jl_alloc_genericmemory({} addrspace(10)* addrspacecast ({}* inttoptr (i64 4727291568 to {}*) to {} addrspace(10)*), i64 1), !dbg !1083
%79 = bitcast {} addrspace(10)* %78 to <{ i64, i8* }> addrspace(10)*, !dbg !1083
%80 = getelementptr inbounds <{ i64, i8* }>, <{ i64, i8* }> addrspace(10)* %79, i32 0, i32 1, !dbg !1083
%81 = load i8*, i8* addrspace(10)* %80, align 8, !dbg !1083
call void @llvm.memset.p0i8.i64(i8* align 8 %81, i8 0, i64 8, i1 false), !dbg !1083
%82 = insertvalue [2 x {} addrspace(10)*] %77, {} addrspace(10)* %78, 1, !dbg !1083
%83 = getelementptr inbounds { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }* %3, i32 0, i32 4, !dbg !1083
store [2 x {} addrspace(10)*] %82, [2 x {} addrspace(10)*]* %83, align 8, !dbg !1083
%84 = call noalias "enzyme_type"="{[-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]:Pointer, [-1,8,-1]:Float@double}" {} addrspace(10)* @jl_alloc_genericmemory({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 4727291568 to {}*) to {} addrspace(10)*), i64 noundef 1) #19, !dbg !1083, !noalias !987
%"'ipc61" = bitcast {} addrspace(10)* %73 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !1086
%"'ipc62" = bitcast {} addrspace(10)* %78 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !1086
%85 = bitcast {} addrspace(10)* %84 to { i64, {} addrspace(10)** } addrspace(10)*, !dbg !1086
%"'ipc63" = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %"'ipc61" to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !1086
%"'ipc64" = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %"'ipc62" to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !1086
%86 = addrspacecast { i64, {} addrspace(10)** } addrspace(10)* %85 to { i64, {} addrspace(10)** } addrspace(11)*, !dbg !1086
%"'ipg65" = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %"'ipc63", i64 0, i32 1, !dbg !1086
%"'ipg66" = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %"'ipc64", i64 0, i32 1, !dbg !1086
%87 = getelementptr inbounds { i64, {} addrspace(10)** }, { i64, {} addrspace(10)** } addrspace(11)* %86, i64 0, i32 1, !dbg !1086
%"'ipc67" = bitcast {} addrspace(10)** addrspace(11)* %"'ipg65" to i8* addrspace(11)*, !dbg !1086
%"'ipc68" = bitcast {} addrspace(10)** addrspace(11)* %"'ipg66" to i8* addrspace(11)*, !dbg !1086
%88 = bitcast {} addrspace(10)** addrspace(11)* %87 to i8* addrspace(11)*, !dbg !1086
%"'ipl69" = load i8*, i8* addrspace(11)* %"'ipc67", align 8, !dbg !1086, !tbaa !17, !alias.scope !1088, !noalias !1091, !nonnull !0
%"'ipl70" = load i8*, i8* addrspace(11)* %"'ipc68", align 8, !dbg !1086, !tbaa !17, !alias.scope !1094, !noalias !1095, !nonnull !0
%89 = load i8*, i8* addrspace(11)* %88, align 8, !dbg !1086, !tbaa !17, !alias.scope !1096, !noalias !1097, !nonnull !0, !enzyme_type !51, !enzymejl_byref_BITS_VALUE !0, !enzymejl_source_type_Ptr\7BFloat64\7D !0, !enzyme_nocache !0
%90 = bitcast {}*** %current_task1.i15 to {}*, !dbg !1098
%"'mi58" = call noalias nonnull align 8 dereferenceable(24) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Pointer, [-1,8,0]:Integer, [-1,8,1]:Integer, [-1,8,2]:Integer, [-1,8,3]:Integer, [-1,8,4]:Integer, [-1,8,5]:Integer, [-1,8,6]:Integer, [-1,8,7]:Integer, [-1,8,8]:Pointer, [-1,8,8,-1]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %90, i64 noundef 24, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 4727291376 to {}*) to {} addrspace(10)*)) #20, !dbg !1098
%91 = bitcast {} addrspace(10)* %"'mi58" to i8 addrspace(10)*, !dbg !1098
call void @llvm.memset.p10i8.i64(i8 addrspace(10)* nonnull dereferenceable(24) dereferenceable_or_null(24) %91, i8 0, i64 24, i1 false), !dbg !1098
%92 = insertvalue [2 x {} addrspace(10)*] undef, {} addrspace(10)* %"'mi58", 0, !dbg !1098
%"'mi59" = call noalias nonnull align 8 dereferenceable(24) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Pointer, [-1,8,0]:Integer, [-1,8,1]:Integer, [-1,8,2]:Integer, [-1,8,3]:Integer, [-1,8,4]:Integer, [-1,8,5]:Integer, [-1,8,6]:Integer, [-1,8,7]:Integer, [-1,8,8]:Pointer, [-1,8,8,-1]:Float@double, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer}" {} addrspace(10)* @julia.gc_alloc_obj({}* nonnull %90, i64 noundef 24, {} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 4727291376 to {}*) to {} addrspace(10)*)) #20, !dbg !1098
%93 = bitcast {} addrspace(10)* %"'mi59" to i8 addrspace(10)*, !dbg !1098
call void @llvm.memset.p10i8.i64(i8 addrspace(10)* nonnull dereferenceable(24) dereferenceable_or_null(24) %93, i8 0, i64 24, i1 false), !dbg !1098
%94 = insertvalue [2 x {} addrspace(10)*] %92, {} addrspace(10)* %"'mi59", 1, !dbg !1098
%95 = getelementptr inbounds { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }* %3, i32 0, i32 3, !dbg !1098
store [2 x {} addrspace(10)*] %94, [2 x {} addrspace(10)*]* %95, align 8, !dbg !1098
%"'ipc50" = bitcast {} addrspace(10)* %"'mi58" to { i8*, {} addrspace(10)* } addrspace(10)*, !dbg !1098
%"'ipc51" = bitcast {} addrspace(10)* %"'mi59" to { i8*, {} addrspace(10)* } addrspace(10)*, !dbg !1098
%"'ipc52" = addrspacecast { i8*, {} addrspace(10)* } addrspace(10)* %"'ipc50" to { i8*, {} addrspace(10)* } addrspace(11)*, !dbg !1098
%"'ipc53" = addrspacecast { i8*, {} addrspace(10)* } addrspace(10)* %"'ipc51" to { i8*, {} addrspace(10)* } addrspace(11)*, !dbg !1098
%".repack'ipg" = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %"'ipc52", i64 0, i32 0, !dbg !1098
%".repack'ipg55" = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %"'ipc53", i64 0, i32 0, !dbg !1098
store i8* %"'ipl69", i8* addrspace(11)* %".repack'ipg", align 8, !dbg !1098, !tbaa !49, !alias.scope !1099, !noalias !1102
store i8* %"'ipl70", i8* addrspace(11)* %".repack'ipg55", align 8, !dbg !1098, !tbaa !49, !alias.scope !1107, !noalias !1108
%".repack19'ipg" = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %"'ipc52", i64 0, i32 1, !dbg !1098
%".repack19'ipg54" = getelementptr inbounds { i8*, {} addrspace(10)* }, { i8*, {} addrspace(10)* } addrspace(11)* %"'ipc53", i64 0, i32 1, !dbg !1098
store {} addrspace(10)* %73, {} addrspace(10)* addrspace(11)* %".repack19'ipg", align 8, !dbg !1098, !tbaa !49, !alias.scope !1099, !noalias !1102
store {} addrspace(10)* %78, {} addrspace(10)* addrspace(11)* %".repack19'ipg54", align 8, !dbg !1098, !tbaa !49, !alias.scope !1107, !noalias !1108
%"'ipc39" = bitcast {} addrspace(10)* %"'mi58" to i8 addrspace(10)*, !dbg !1098
%"'ipc40" = bitcast {} addrspace(10)* %"'mi59" to i8 addrspace(10)*, !dbg !1098
%"'ipc41" = addrspacecast i8 addrspace(10)* %"'ipc39" to i8 addrspace(11)*, !dbg !1098
%"'ipc42" = addrspacecast i8 addrspace(10)* %"'ipc40" to i8 addrspace(11)*, !dbg !1098
%"'ipg43" = getelementptr inbounds i8, i8 addrspace(11)* %"'ipc41", i64 16, !dbg !1098
%"'ipg44" = getelementptr inbounds i8, i8 addrspace(11)* %"'ipc42", i64 16, !dbg !1098
%"'ipc45" = bitcast i8 addrspace(11)* %"'ipg43" to i64 addrspace(11)*, !dbg !1098
%"'ipc46" = bitcast i8 addrspace(11)* %"'ipg44" to i64 addrspace(11)*, !dbg !1098
store i64 1, i64 addrspace(11)* %"'ipc45", align 8, !dbg !1098, !tbaa !30, !alias.scope !1099, !noalias !1102
store i64 1, i64 addrspace(11)* %"'ipc46", align 8, !dbg !1098, !tbaa !30, !alias.scope !1107, !noalias !1108
%"'ipc37" = bitcast i8* %"'ipl69" to {} addrspace(10)**, !dbg !1109
%"'ipc38" = bitcast i8* %"'ipl70" to {} addrspace(10)**, !dbg !1109
%96 = bitcast i8* %89 to {} addrspace(10)**, !dbg !1109
%97 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %73, {} addrspace(10)** %"'ipc37"), !dbg !1112
%98 = call {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* %78, {} addrspace(10)** %"'ipc38"), !dbg !1112
%99 = call "enzyme_type"="{[-1]:Pointer, [-1,-1]:Float@double}" {} addrspace(10)* addrspace(13)* @julia.gc_loaded({} addrspace(10)* noundef %84, {} addrspace(10)** noundef %96) #18, !dbg !1112
%100 = bitcast {} addrspace(10)* addrspace(13)* %99 to double addrspace(13)*, !dbg !1112
store double %72, double addrspace(13)* %100, align 8, !dbg !1112, !tbaa !58, !alias.scope !1113, !noalias !1116
%".fca.1.insert'ipiv" = insertvalue { double, {} addrspace(10)* } zeroinitializer, {} addrspace(10)* %"'mi58", 1, !dbg !1119
%101 = insertvalue [2 x { double, {} addrspace(10)* }] undef, { double, {} addrspace(10)* } %".fca.1.insert'ipiv", 0, !dbg !1119
%".fca.1.insert'ipiv72" = insertvalue { double, {} addrspace(10)* } zeroinitializer, {} addrspace(10)* %"'mi59", 1, !dbg !1119
%102 = insertvalue [2 x { double, {} addrspace(10)* }] %101, { double, {} addrspace(10)* } %".fca.1.insert'ipiv72", 1, !dbg !1119
%103 = getelementptr inbounds { { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { double, {} addrspace(10)* } }, { { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { double, {} addrspace(10)* } }* %2, i32 0, i32 1, !dbg !1119
store [2 x { double, {} addrspace(10)* }] %102, { double, {} addrspace(10)* }* %103, align 8, !dbg !1119
%104 = load { { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { double, {} addrspace(10)* } }, { { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { double, {} addrspace(10)* } }* %2, align 8, !dbg !1119
ret { { { [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], {} addrspace(10)*, i64, double, double, double, double* }, double, {} addrspace(10)*, [2 x {} addrspace(10)*], [2 x {} addrspace(10)*], double }, { double, {} addrspace(10)* } } %104, !dbg !1119
}
ERROR: LLVM error: augmented function failed verification (3)
Stacktrace:
[1] handle_error(reason::Cstring)
@ LLVM ~/.julia/packages/LLVM/UFrs4/src/core/context.jl:194
Metadata
Metadata
Assignees
Labels
No labels