This is an archive of the discontinued LLVM Phabricator instance.

[libc] Implement 'errno' on the GPU as a global integer internally
ClosedPublic

Authored by jhuber6 on Jun 2 2023, 10:52 AM.

Details

Summary

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.

Diff Detail

Event Timeline

jhuber6 created this revision.Jun 2 2023, 10:52 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 2 2023, 10:52 AM
jhuber6 requested review of this revision.Jun 2 2023, 10:52 AM
lntue accepted this revision.Jun 2 2023, 11:56 AM
This revision is now accepted and ready to land.Jun 2 2023, 11:56 AM