Skip to content

Commit 18f89a4

Browse files
authored
Change VOLATILE_MEMORY_BARRIER for x64 Unix (#131807)
Currently the macro is defined as asm volatile ("" : : : "memory"). That caused a recent regression in HndWriteBarrier due to an added VolatileStore where clang adds an extra dummy jmp instruction to the very next location after a call to HndWriteBarrierWorker. This happens due to LLVM internal handling of the asm volatile ("" : : : "memory"). This change fixes it by replacing the barrier definition for x64 Unix by __atomic_signal_fence(__ATOMIC_SEQ_CST) This is a pure compiler only barrier and it doesn't introduce the side effect like the asm volatile ("" : : : "memory"). Close #130698
1 parent 23ec3d9 commit 18f89a4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/coreclr/gc/env/volatile.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
// Please do not use this macro outside of this file. It is subject to change or removal without
9191
// notice.
9292
//
93-
#define VOLATILE_MEMORY_BARRIER() asm volatile ("" : : : "memory")
93+
#define VOLATILE_MEMORY_BARRIER() __atomic_signal_fence(__ATOMIC_SEQ_CST)
9494
#endif // HOST_ARM || HOST_ARM64
9595
#elif (defined(HOST_ARM) || defined(HOST_ARM64)) && _ISO_VOLATILE
9696
// ARM & ARM64 have a very weak memory model and very few tools to control that model. We're forced to perform a full

‎src/coreclr/inc/volatile.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
// Please do not use this macro outside of this file. It is subject to change or removal without
101101
// notice.
102102
//
103-
#define VOLATILE_MEMORY_BARRIER() asm volatile ("" : : : "memory")
103+
#define VOLATILE_MEMORY_BARRIER() __atomic_signal_fence(__ATOMIC_SEQ_CST)
104104
#endif // HOST_ARM || HOST_ARM64
105105

106106
#elif (defined(HOST_ARM) || defined(HOST_ARM64)) && _ISO_VOLATILE

0 commit comments

Comments
 (0)