[all-commits] [llvm/llvm-project] cfde5f: [libc] Implement 'errno' on the GPU as a global in...

Joseph Huber via All-commits all-commits at lists.llvm.org
Fri Jun 2 12:16:40 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cfde5f2d8969040611d24075a571d485ab62cb27
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2023-06-02 (Fri, 02 Jun 2023)

  Changed paths:
    M libc/src/errno/libc_errno.cpp
    M libc/src/errno/libc_errno.h

  Log Message:
  [libc] Implement 'errno' on the GPU as a global integer internally

The C standard asserts that the `errno` value is an l-value thread local
integer. We cannot provide a generic thread local integer on the GPU
currently without some workarounds. Previously, we worked around this by
implementing the `errno` value as a special consumer class that made all
the writes disappear. However, this is problematic for internal tests.
Currently there are build failures because of this handling and it's
only likely to cause more problems the more we do this.

This patch instead makes the internal target used for testing export the
`errno` value as a simple global integer. This allows us to use and test
the `errno` interface correctly assuming we run with a single thread.
Because this is only used for the non-exported target we still do not
provide this feature in the version that users will use so we do not
need to worrk about it being incorrect in general.

Reviewed By: lntue

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

More information about the All-commits mailing list