[all-commits] [llvm/llvm-project] 04a309: [libc] Adding memcpy implementation for x86_64

Guillaume Chatelet via All-commits all-commits at lists.llvm.org
Wed Mar 18 09:48:34 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 04a309dd0be3aea17ab6e84f8bfc046c1f044be2
      https://github.com/llvm/llvm-project/commit/04a309dd0be3aea17ab6e84f8bfc046c1f044be2
  Author: Guillaume Chatelet <gchatelet at google.com>
  Date:   2020-03-18 (Wed, 18 Mar 2020)

  Changed paths:
    M libc/CMakeLists.txt
    M libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
    M libc/cmake/modules/LLVMLibCRules.cmake
    R libc/cmake/modules/cpu_features/check_avx.cpp
    R libc/cmake/modules/cpu_features/check_avx512f.cpp
    A libc/cmake/modules/cpu_features/check_cpu_features.cpp.in
    R libc/cmake/modules/cpu_features/check_sse.cpp
    R libc/cmake/modules/cpu_features/check_sse2.cpp
    M libc/lib/CMakeLists.txt
    M libc/src/string/CMakeLists.txt
    A libc/src/string/memcpy.cpp
    A libc/src/string/memcpy.h
    A libc/src/string/memcpy_arch_specific.h.def
    M libc/src/string/memory_utils/CMakeLists.txt
    A libc/src/string/memory_utils/memcpy_utils.h
    M libc/src/string/memory_utils/utils.h
    A libc/src/string/x86/CMakeLists.txt
    A libc/src/string/x86/memcpy_arch_specific.h.inc
    M libc/test/src/string/CMakeLists.txt
    A libc/test/src/string/memcpy_test.cpp
    M libc/test/src/string/memory_utils/CMakeLists.txt
    A libc/test/src/string/memory_utils/memcpy_utils_test.cpp
    M libc/test/src/string/memory_utils/utils_test.cpp

  Log Message:
  -----------
  [libc] Adding memcpy implementation for x86_64

Summary:
The patch is not ready yet and is here to discuss a few options:
 - How do we customize the implementation? (i.e. how to define `kRepMovsBSize`),
 - How do we specify custom compilation flags? (We'd need `-fno-builtin-memcpy` to be passed in),
 - How do we build? We may want to test in debug but build the libc with `-march=native` for instance,
 - Clang has a brand new builtin `__builtin_memcpy_inline` which makes the implementation easy and efficient, but:
   - If we compile with `gcc` or `msvc` we can't use it, resorting on less efficient code generation,
   - With gcc we can use `__builtin_memcpy` but then we'd need a postprocess step to check that the final assembly do not contain call to `memcpy` (unlikely but allowed),
   - For msvc we'd need to resort on the compiler optimization passes.

Reviewers: sivachandra, abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits, courbet

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D74397




More information about the All-commits mailing list