[GHC] #8219: x86 definition of cas() is wrong

GHC ghc-devs at haskell.org
Tue Sep 3 23:32:40 CEST 2013


#8219: x86 definition of cas() is wrong
-------------------------------------+------------------------------------
        Reporter:  parcs             |            Owner:
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Runtime System    |          Version:  7.7
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by parcs):

 Test case:

 === cas.c
 {{{
 #!c
 static int
 cas (int *p, int o, int n)
 {
     asm ("lock cmpxchg %2,%1"
             :"=a"(o), "=m"(*(volatile int *)p)
             :"0"(o), "r"(n));
     return o;
 }

 int v;

 int
 main (int argc, char **argv)
 {
     /* The following assignment gets removed unless you change "=m" to
 "+m". */
     v = 42;
     cas (&v, 0, 1);

     return 0;
 }
 return 0;
 }}}


 === Command Line
 {{{
 $ gcc -O2 -S cas.c
 $ grep 42 cas.s
 zsh: exit 1
 $ perl -i -pe 's/=m/+m/' cas.c
 $ gcc -O2 -S cas.c
 $ grep 42 cas.s
         movl    $42, v(%rip)
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8219#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler




More information about the ghc-tickets mailing list