Consider the following:
t = (1, 2) # a Tuple{Int64, Int64}
@code_llvm identity(t)
@code_llvm Tuple{Int64, Int64}(t)
@code_llvm convert(Tuple{Int64, Int64}, t)
The LLVM for all of these is the same (apart from the definition name):
define void @jlsys_convert_61082([2 x i64] addrspace(11)* noalias nocapture sret, %jl_value_t addrspace(10)*, [2 x i64] addrspace(11)* nocapture readonly dereferenceable(16)) #0 !dbg !5 {
top:
%3 = bitcast [2 x i64] addrspace(11)* %2 to i8 addrspace(11)*
%4 = bitcast [2 x i64] addrspace(11)* %0 to i8 addrspace(11)*
call void @llvm.memcpy.p11i8.p11i8.i32(i8 addrspace(11)* %4, i8 addrspace(11)* %3, i32 16, i32 1, i1 false)
ret void
}
I would have expected this to be a no-op, as it is for Float64
, Array
, etc., but there’s an llvm.memcpy
. Is this a performance bug, or is this copy necessary somehow? If the latter is the case (which would be weird to me, since Tuple
s are immutable), is there a way to elide the copy in convert
calls?