Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
ldc.arrayinit: Use C memcpy instead of LLVM intrinsic directly
Browse files Browse the repository at this point in the history
The intrinsic's signature has changed for LLVM 7. ldc.arrayinit is the
only druntime/Phobos module using it, so just use the C function (or let
LLVM optimize it) to keep the adaptations minimal.
  • Loading branch information
kinke committed Aug 21, 2018
1 parent d26a9a7 commit 694089c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ldc/arrayinit.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ private import ldc.intrinsics;
extern(C):

int memcmp(void*,void*,size_t);
void* memcpy(void*, const(void)*, size_t);
size_t strlen(char*);

// per-element array init routines
Expand Down Expand Up @@ -94,7 +95,7 @@ void _d_array_init_mem(void* a, size_t na, void* v, size_t nv)
auto p = a;
auto end = a + na*nv;
while (p !is end) {
llvm_memcpy(p,v,nv,0);
memcpy(p,v,nv);
p += nv;
}
}
Expand Down Expand Up @@ -146,7 +147,7 @@ void _d_array_slice_copy(void* dst, size_t dstlen, void* src, size_t srclen)
if (dstlen != srclen)
throw new Exception("lengths don't match for array copy");
else if (dst+dstlen <= src || src+srclen <= dst)
llvm_memcpy!size_t(dst, src, dstlen, 0);
memcpy(dst, src, dstlen);
else
throw new Exception("overlapping array copy");
}

0 comments on commit 694089c

Please sign in to comment.