[libcxx-commits] [PATCH] D91911: [libc++] Add a 'is-lockfree-runtime-function' lit feature
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 27 12:00:37 PST 2020
ldionne added a comment.
How difficult would it be to implement `__atomic_is_lock_free` in compiler-rt? I think something like this in `atomic.c` would work:
int __atomic_is_lock_free(size_t size, void const volatile* ptr) {
#define LOCK_FREE_ACTION(type) return sizeof(type) <= size;
LOCK_FREE_CASES(ptr);
#undef LOCK_FREE_ACTION
return 0;
}
However, I'm not familiar with how to add builtins in compiler-rt, and I haven't been able to figure out the details at a glance.
Do I understand correctly that:
1. When Clang sees `__atomic_is_lock_free(args...)`, it tries to generate code directly for it if it can.
2. Otherwise, it generates an external call to a function called `int __atomic_is_lock_free(unsigned long, void const volatile*);`
3. If a library that defines this function isn't provided, a linker error follows
Is that how these work? We can definitely add a workaround to fix the test suite here, however I'd also like to actually solve the root cause of this issue. It's also something we've had requests about in the past.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91911/new/
https://reviews.llvm.org/D91911
More information about the libcxx-commits
mailing list