[libc-commits] [libc] [libc] memmove optimizations (PR #70043)

Dmitry Vyukov via libc-commits libc-commits at lists.llvm.org
Wed Oct 25 01:56:27 PDT 2023


dvyukov wrote:

> But I'm not sure if introducing the fast_only argument is the way to go, it makes the logic spread across several files and is harder to reason about. I need to think about it.

A slightly cleaner way to do it may be to return true/false from inline_memmove instead of the separate LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SLOW_SIZE.

```
bool inline_memmove(void *dst, const void *src, size_t count, bool fast_only) {
 if (size == 0) return true;
 ...
 if (fast_only) return false;
 ...
}

void memmove(...) {
  if (inline_memmove(..., true))
    return;
}
```

I did not do it only because it breaks all of the nice returns of voids :)
```
  if (count == 1)
    return generic::Memmove<uint8_t>::block(dst, src);
```

https://github.com/llvm/llvm-project/pull/70043


More information about the libc-commits mailing list