# compiler-rt: fix memcpy generating recursive calls · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/6dc1a4db7f9561dd2b84a99159b3ad7b55958717)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 6dc1a4db7f9561dd2b84a99159b3ad7b55958717

Requested commit: 6dc1a4db7f9561dd2b84a99159b3ad7b55958717

Commit: 6dc1a4db7f9561dd2b84a99159b3ad7b55958717

Tree: dec4044e1316dcffba1d1a2b346f307e89dd8d62

Author: dweiller

Committer: Andrew Kelley

## Message

```
compiler-rt: fix memcpy generating recursive calls

When using the LLVM backend, array copies were lowered as calls to
`llvm.memcpy.*` builtin which could cause recursive calls to memcpy to
be generated (observed with `-target x86_64-linux -mcpu x86_64+avx512vl
--debug-rt`).

By instead performing these small fixed-size copies with integers or
vectors the LLVM backend does not generate calls to the `llvm.memcpy`
builtin, and so (with `-fno-builtin`) recursive calls to memcpy will
not be generated by LLVM.

The assertions and (test build) runtime safety have been removed as they
may cause (mutually) recursive calls to memcpy in debug builds since the
panic handler generates calls to llvm.memcpy.

```

## Parents

- [c2a3d8cbb935ae68a5bd95d45c65b0f7f32974b0](https://git.cafe/gitcafe/zig/commit/c2a3d8cbb935ae68a5bd95d45c65b0f7f32974b0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/6dc1a4db7f9561dd2b84a99159b3ad7b55958717?format=markdown)
