From 81fec44ea5303efa27fb0f04ba06f162ffdfb2df Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Fri, 15 Sep 2017 11:23:31 -0700 Subject: [PATCH] atomic asm snippets: Replace "memory" clobber with "Q" constraint In our atomic asm snippets, using the "Q" constraint, (https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html tells gcc which exact memory is modified i.e. the bytes covered by the atomic variable), is better than using the "memory" clobber (tells gcc that all memory is modified, effectively a compiler memory barrier which prevents compiler optimizations). --- open-vm-tools/lib/include/vm_atomic.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/open-vm-tools/lib/include/vm_atomic.h b/open-vm-tools/lib/include/vm_atomic.h index 45775938e..e089d0027 100644 --- a/open-vm-tools/lib/include/vm_atomic.h +++ b/open-vm-tools/lib/include/vm_atomic.h @@ -307,23 +307,24 @@ Atomic_ReadIfEqualWrite128(Atomic_uint128 *ptr, // IN/OUT uint32 failed; LDST_LDST_MEM_BARRIER(); - __asm__ __volatile__ ( - "1: ldxp %x0, %x1, [%3] \n\t" + __asm__ __volatile__( + "1: ldxp %x0, %x1, %3 \n\t" " cmp %x0, %x4 \n\t" " ccmp %x1, %x5, #0, eq \n\t" " b.ne 2f \n\t" - " stxp %w2, %x6, %x7, [%3] \n\t" + " stxp %w2, %x6, %x7, %3 \n\t" " cbnz %w2, 1b \n\t" "2: clrex \n\t" : "=&r" (res.lo), "=&r" (res.hi), - "=&r" (failed) - : "r" (&ptr->value), - "r" (_old.lo), + "=&r" (failed), + "+Q" (ptr->value) + : "r" (_old.lo), "r" (_old.hi), "r" (_new.lo), "r" (_new.hi) - : "cc", "memory"); + : "cc" + ); LDST_LDST_MEM_BARRIER(); return res.raw; -- 2.47.3