pub unsafe fn gen_clone(
        &mut self,
        builder: LLVMBuilderRef,
        intrinsics: &mut Intrinsics,
        vector: LLVMValueRef,
        run: LLVMValueRef,
    ) -> WeldResult<LLVMValueRef> {
        if self.clone.is_none() {
            let mut arg_tys = [self.vector_ty, self.run_handle_type()];
            let ret_ty = self.vector_ty;

            let name = format!("{}.clone", self.name);
            let (function, builder, _) = self.define_function(ret_ty, &mut arg_tys, name);

            let vector = LLVMGetParam(function, 0);
            let run = LLVMGetParam(function, 1);

            let elem_size = self.size_of(self.elem_ty);
            let size = LLVMBuildExtractValue(builder, vector, SIZE_INDEX, c_str!(""));
            let alloc_size = LLVMBuildMul(builder, elem_size, size, c_str!("size"));

            let dst_bytes =
                intrinsics.call_weld_run_malloc(builder, run, alloc_size, Some(c_str!("")));
            let source_bytes = LLVMBuildExtractValue(builder, vector, POINTER_INDEX, c_str!(""));
            let source_bytes =
                LLVMBuildBitCast(builder, source_bytes, self.void_pointer_type(), c_str!(""));
            let _ = intrinsics.call_memcpy(builder, dst_bytes, source_bytes, alloc_size);

            let elements = LLVMBuildBitCast(
                builder,
                dst_bytes,
                LLVMPointerType(self.elem_ty, 0),
                c_str!(""),
            );
            let result = LLVMBuildInsertValue(
                builder,
                LLVMGetUndef(self.vector_ty),
                elements,
                POINTER_INDEX,
                c_str!(""),
            );
            let result = LLVMBuildInsertValue(builder, result, size, SIZE_INDEX, c_str!(""));
            LLVMBuildRet(builder, result);

            self.clone = Some(function);
            LLVMDisposeBuilder(builder);
        }

        let mut args = [vector, run];
        Ok(LLVMBuildCall(
            builder,
            self.clone.unwrap(),
            args.as_mut_ptr(),
            args.len() as u32,
            c_str!(""),
        ))
    }
Generates the `clone` method on vectors and calls it.

The clone method performs a shallow copy of the vector.
weld/src/codegen/llvm2/vector.rs