Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the static analyzer happier in aarch64-darwin #51861

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/debug-registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ class JITDebugInfoRegistry

struct libc_frames_t {
#if defined(_OS_DARWIN_) && defined(LLVM_SHLIB)
std::atomic<void(*)(void*)> libc_register_frame_{nullptr};
std::atomic<void(*)(void*)> libc_deregister_frame_{nullptr};
typedef void (*frame_register_func)(void *) JL_NOTSAFEPOINT;
std::atomic<frame_register_func> libc_register_frame_{nullptr};
std::atomic<frame_register_func> libc_deregister_frame_{nullptr};

void libc_register_frame(const char *Entry) JL_NOTSAFEPOINT;

Expand Down
4 changes: 2 additions & 2 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ static int lookup_pointer(
#if defined(_OS_DARWIN_) && defined(LLVM_SHLIB)

void JITDebugInfoRegistry::libc_frames_t::libc_register_frame(const char *Entry) {
auto libc_register_frame_ = jl_atomic_load_relaxed(&this->libc_register_frame_);
frame_register_func libc_register_frame_ = jl_atomic_load_relaxed(&this->libc_register_frame_);
if (!libc_register_frame_) {
libc_register_frame_ = (void(*)(void*))dlsym(RTLD_NEXT, "__register_frame");
jl_atomic_store_release(&this->libc_register_frame_, libc_register_frame_);
Expand All @@ -562,7 +562,7 @@ void JITDebugInfoRegistry::libc_frames_t::libc_register_frame(const char *Entry)
}

void JITDebugInfoRegistry::libc_frames_t::libc_deregister_frame(const char *Entry) {
auto libc_deregister_frame_ = jl_atomic_load_relaxed(&this->libc_deregister_frame_);
frame_register_func libc_deregister_frame_ = jl_atomic_load_relaxed(&this->libc_deregister_frame_);
if (!libc_deregister_frame_) {
libc_deregister_frame_ = (void(*)(void*))dlsym(RTLD_NEXT, "__deregister_frame");
jl_atomic_store_release(&this->libc_deregister_frame_, libc_deregister_frame_);
Expand Down
10 changes: 5 additions & 5 deletions src/stackwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ _os_tsd_get_direct(unsigned long slot)
// Unconditionally defined ptrauth_strip (instead of using the ptrauth.h header)
// since libsystem will likely be compiled with -mbranch-protection, and we currently are not.
// code from https://github.com/llvm/llvm-project/blob/7714e0317520207572168388f22012dd9e152e9e/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) {
static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) JL_NOTSAFEPOINT {
// On the stack the link register is protected with Pointer
// Authentication Code when compiled with -mbranch-protection.
// Let's strip the PAC unconditionally because xpaclri is in the NOP space,
Expand All @@ -809,7 +809,7 @@ static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) {

__attribute__((always_inline, pure))
static __inline__ void**
_os_tsd_get_base(void)
_os_tsd_get_base(void) JL_NOTSAFEPOINT
{
#if defined(__arm__)
uintptr_t tsd;
Expand All @@ -831,22 +831,22 @@ _os_tsd_get_base(void)
#ifdef _os_tsd_get_base
__attribute__((always_inline))
static __inline__ void*
_os_tsd_get_direct(unsigned long slot)
_os_tsd_get_direct(unsigned long slot) JL_NOTSAFEPOINT
{
return _os_tsd_get_base()[slot];
}
#endif

__attribute__((always_inline, pure))
static __inline__ uintptr_t
_os_ptr_munge_token(void)
_os_ptr_munge_token(void) JL_NOTSAFEPOINT
{
return (uintptr_t)_os_tsd_get_direct(__TSD_PTR_MUNGE);
}

__attribute__((always_inline, pure))
JL_UNUSED static __inline__ uintptr_t
_os_ptr_munge(uintptr_t ptr)
_os_ptr_munge(uintptr_t ptr) JL_NOTSAFEPOINT
{
return ptr ^ _os_ptr_munge_token();
}
Expand Down