rts: Fix aarch64 implementation of xchg
authorErik de Castro Lopo <erikd@mega-nerd.com>
Thu, 28 May 2015 02:57:28 +0000 (02:57 +0000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 1 Jun 2015 09:40:07 +0000 (19:40 +1000)
In the previous implementation, the `stlxr` instruction clobbered
the value that was supposed to be returned by the the `xchg`
function.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Test Plan: build on aarch64

Reviewers: austin, bgamari, rwbarton

Subscribers: bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D932

includes/stg/SMP.h

index 10ef83e..fbc8bdc 100644 (file)
@@ -158,13 +158,11 @@ xchg(StgPtr p, StgWord w)
                           : "memory"
                           );
 #elif aarch64_HOST_ARCH
-    // Don't think we actually use tmp here, but leaving
-    // it for consistent numbering
     StgWord tmp; 
     __asm__ __volatile__ (
                           "1:    ldaxr  %0, [%3]\n"
-                          "      stlxr  %w0, %2, [%3]\n"
-                          "      cbnz   %w0, 1b\n"
+                          "      stlxr  %w1, %2, [%3]\n"
+                          "      cbnz   %w1, 1b\n"
                           "      dmb sy\n"
                           : "=&r" (result), "=&r" (tmp)
                           : "r" (w), "r" (p)