fix broken constraints for powerpc atomic cas asm
authorRich Felker <dalias@aerifal.cx>
Sat, 19 Jul 2014 16:19:20 +0000 (12:19 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 28 Jul 2014 04:28:00 +0000 (00:28 -0400)
the register constraint for the address to be accessed did not convey
that the asm can access the pointed-to object. as far as the compiler
could tell, the result of the asm was just a pure function of the
address and the values passed in, and thus the asm could be hoisted
out of loops or omitted entirely if the result was not used.

(cherry picked from commit 7fdae458bd421046a300a69dcb32953ac9450136)

arch/powerpc/atomic.h

index d52ee0c6bfb90b520ef48c9497fa858fe9cd09c9..05951a2de7055f2695fe34c638e071fd89a0072b 100644 (file)
@@ -31,7 +31,7 @@ static inline int a_cas(volatile int *p, int t, int s)
                "       stwcx. %3, 0, %1\n"
                "       bne- 1b\n"
                "1:     \n"
-               : "=&r"(t) : "r"(p), "r"(t), "r"(s) : "cc", "memory" );
+               : "=&r"(t), "+m"(*p) : "r"(t), "r"(s) : "cc", "memory" );
         return t;
 }