[all-commits] [llvm/llvm-project] d85699: [libc] Move strdup implementation to a new header

Joseph Huber via All-commits all-commits at lists.llvm.org
Tue Nov 29 12:52:13 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d85699eb7d90571b8c39b86774e4ac98058d56f0
      https://github.com/llvm/llvm-project/commit/d85699eb7d90571b8c39b86774e4ac98058d56f0
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-11-29 (Tue, 29 Nov 2022)

  Changed paths:
    M libc/src/string/CMakeLists.txt
    A libc/src/string/allocating_string_utils.h
    M libc/src/string/strdup.cpp
    M libc/src/string/string_utils.h
    M libc/src/unistd/linux/getcwd.cpp

  Log Message:
  -----------
  [libc] Move strdup implementation to a new header

The `strdup` family of functions rely on `malloc` to be implemented.
Its presence in the `string_utils.h` header meant that compiling many of
the string functions relied on `malloc` being implementated as well.
This patch simply moves the implementation into a new file to avoid
including `stdlib.h` from the other string functions. This was a barrier
for compiling string functions for the GPU where there is no malloc
currently.

Reviewed By: sivachandra

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


  Commit: 55151e138db1b0c95a97ce14d2dfaf86bb6f713f
      https://github.com/llvm/llvm-project/commit/55151e138db1b0c95a97ce14d2dfaf86bb6f713f
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-11-29 (Tue, 29 Nov 2022)

  Changed paths:
    M libc/CMakeLists.txt
    M libc/cmake/modules/LLVMLibCArchitectures.cmake
    M libc/cmake/modules/LLVMLibCObjectRules.cmake
    A libc/config/gpu/api.td
    A libc/config/gpu/entrypoints.txt
    A libc/config/gpu/headers.txt
    M libc/src/__support/architectures.h
    M libc/src/__support/common.h
    M libc/src/string/memory_utils/bcmp_implementations.h
    M libc/src/string/memory_utils/memcmp_implementations.h
    M libc/src/string/memory_utils/memcpy_implementations.h
    M libc/src/string/memory_utils/memmove_implementations.h
    M libc/src/string/memory_utils/memset_implementations.h
    M libc/utils/CMakeLists.txt

  Log Message:
  -----------
  [libc] Add initial support for a libc implementation for the GPU

This patch contains the initial support for building LLVM's libc as a
target for the GPU. Currently this only supports a handful of very basic
functions that can be implemented without an operating system. The GPU
code is build using the existing OpenMP toolchain. This allows us to
minimally change the existing codebase and get a functioning static
library. This patch allows users to create a static library called
`libcgpu.a` that contains fat binaries containing device IR.

Current limitations are the lack of test support and the fact that only
one target OS can be built at a time. That is, the user cannot get a
`libc` for Linux and one for the GPU simultaneously.

This introduces two new CMake variables to control the behavior
`LLVM_LIBC_TARET_OS` is exported so the user can now specify it to equal
`"gpu"`. `LLVM_LIBC_GPU_ARCHITECTURES` is also used to configure how
many targets to build for at once.

Depends on D138607

Reviewed By: sivachandra

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


  Commit: 194788b2fd0f82a2069899b8eb81648439d8dbab
      https://github.com/llvm/llvm-project/commit/194788b2fd0f82a2069899b8eb81648439d8dbab
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-11-29 (Tue, 29 Nov 2022)

  Changed paths:
    A libc/docs/gpu_mode.rst
    M libc/docs/index.rst

  Log Message:
  -----------
  [libc][docs] Add documentation for the new GPU mode

This patch introduces documentation for the new GPU mode added in
D138608. The documentation includes instructions for building and using
the library, along with a description of the supported functions and
headers.

Reviewed By: sivachandra, lntue, michaelrj

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


Compare: https://github.com/llvm/llvm-project/compare/1114d1a9767c...194788b2fd0f


More information about the All-commits mailing list