[libc] Add PAUSE instruction for the RPC spin loop

The other architectures use a brief sleep to defer work during this spin
loop that checks the RPC mailboxes. This patch adds one for x64 to
improve usage when running the server.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D156566
This commit is contained in:
Joseph Huber 2023-07-28 14:46:03 -05:00
parent 4f52210a56
commit 9ffde19d11

View File

@ -26,6 +26,8 @@ LIBC_INLINE void sleep_briefly() {
LIBC_INLINE_ASM("nanosleep.u32 64;" ::: "memory");
#elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
__builtin_amdgcn_s_sleep(2);
#elif defined(LIBC_TARGET_ARCH_IS_X86)
__builtin_ia32_pause();
#else
// Simply do nothing if sleeping isn't supported on this platform.
#endif