From: Janne Grunau Date: Wed, 2 Apr 2014 14:31:28 +0000 (+0200) Subject: checkasm: add memory clobber to read_time inline asm X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c2df1fc65c98e213c444134d5dbbb79d439af4db;p=x264 checkasm: add memory clobber to read_time inline asm The memory acts as compiler barrier preventing aggressive reordering of read_time calls. gcc 4.8 reorders some of initial read_time calls after the second when targeting arm. --- diff --git a/tools/checkasm.c b/tools/checkasm.c index cb889660..837fd1a1 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -90,11 +90,11 @@ static inline uint32_t read_time(void) { uint32_t a = 0; #if HAVE_X86_INLINE_ASM - asm volatile( "rdtsc" :"=a"(a) ::"edx" ); + asm volatile( "rdtsc" : "=a"(a) :: "edx", "memory" ); #elif ARCH_PPC - asm volatile( "mftb %0" : "=r" (a) ); + asm volatile( "mftb %0" : "=r"(a) :: "memory" ); #elif ARCH_ARM // ARMv7 only - asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(a) ); + asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(a) :: "memory" ); #endif return a; }