From f06c4525cf33e194495dc6318432bfadfa3cc072 Mon Sep 17 00:00:00 2001 From: William Moses Date: Tue, 12 Sep 2023 17:28:20 -0500 Subject: [PATCH] Fix array type cast (#1050) --- src/compiler.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/compiler.jl b/src/compiler.jl index a541fe14a7..7c75eace58 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -8024,6 +8024,29 @@ function create_abi_wrapper(enzymefn::LLVM.Function, TT, rettype, actualRetType, end return prev end + elseif isa(tape, LLVM.ArrayType) + if isa(ctype, LLVM.ArrayType) + @assert length(ctype) == length(tape) + for i in 1:length(tape) + ln = copy(lidxs) + push!(ln, i-1) + rn = copy(ridxs) + push!(rn, i-1) + prev = typefix(val, eltype(tape), prev, ln, rn) + end + return prev + end + if isa(ctype, LLVM.StructType) + @assert length(elements(ctype)) == length(tape) + for i in 1:length(tape) + ln = copy(lidxs) + push!(ln, i-1) + rn = copy(ridxs) + push!(rn, i-1) + prev = typefix(val, eltype(tape), prev, ln, rn) + end + return prev + end end if isa(tape, LLVM.IntegerType) && LLVM.width(tape) == 1 && LLVM.width(ctype) != LLVM.width(tape)