This is an archive of the discontinued LLVM Phabricator instance.

[llvm][Support] Use std::atomic for llvm::call_once
Needs RevisionPublic

Authored by yannic on May 7 2020, 10:20 AM.

Details

Reviewers
jfb
efriedma

Diff Detail

Event Timeline

yannic created this revision.May 7 2020, 10:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2020, 10:20 AM
yannic updated this revision to Diff 262710.May 7 2020, 11:37 AM
yannic added a reviewer: jfb.May 7 2020, 11:39 AM
yannic set the repository for this revision to rG LLVM Github Monorepo.
yannic added a subscriber: cfe-commits.
efriedma requested changes to this revision.May 7 2020, 2:41 PM
efriedma added a subscriber: efriedma.

This code is basically untested; I'd rather not touch it until we eventually kill it off. (See the definition of LLVM_THREADING_USE_STD_CALL_ONCE.)

This revision now requires changes to proceed.May 7 2020, 2:41 PM
jfb added a subscriber: brad.May 7 2020, 2:54 PM

is this code still relevant?

#if defined(_MSC_VER)
// MSVC's call_once implementation worked since VS 2015, which is the minimum
// supported version as of this writing.
#define LLVM_THREADING_USE_STD_CALL_ONCE 1
#elif defined(LLVM_ON_UNIX) &&                                                 \
    (defined(_LIBCPP_VERSION) ||                                               \
     !(defined(__NetBSD__) || defined(__OpenBSD__) ||                          \
       (defined(__ppc__) || defined(__PPC__))))
// std::call_once from libc++ is used on all Unix platforms. Other
// implementations like libstdc++ are known to have problems on NetBSD,
// OpenBSD and PowerPC.
#define LLVM_THREADING_USE_STD_CALL_ONCE 1
#elif defined(LLVM_ON_UNIX) &&                                                 \
    ((defined(__ppc__) || defined(__PPC__)) && defined(__LITTLE_ENDIAN__))
#define LLVM_THREADING_USE_STD_CALL_ONCE 1
#else
#define LLVM_THREADING_USE_STD_CALL_ONCE 0
#endif

Seems like something that's probably aged out? Check with @brad since it's from 2016 in b4f6ebf80695. What's the actual problem?

brad added a comment.May 7 2020, 6:06 PM

OpenBSD 6.7 is just wrapping up and will be released in a few days. We have switched to Clang for our PowerPC system compiler and thus libc++. It should be Ok to remove OpenBSD from that bit of code.

The original issue as far as I remember is that because we don't have TLS support it was exposing another code path that could sometimes have deadlocks.