[LLVMbugs] [Bug 22923] New: Incorrect results from atomic builtins

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 16 10:45:35 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=22923

            Bug ID: 22923
           Summary: Incorrect results from atomic builtins
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: nemanja.i.ibm at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This test case is just an instance of the issue. It would appear that the code
for part-word atomic instructions is incorrect (pwr6 and older CPUs). The
availability of the part-word larx/stcx. seems to do away with the problem.

Test case (running on a Power8 LE host):
#include <stdio.h>
signed char sc = 'a';
unsigned char uc = 'b';

int main(void)
{
  __sync_val_compare_and_swap(&sc, 'b', 'c');
  __sync_val_compare_and_swap(&uc, 'b', 'c');
  printf("sc = %c\n", sc);
  printf("uc = %c\n", uc);
}

$ clang --version
clang version 3.7.0 (trunk 231831) (llvm/trunk 231828:231843M)

$ clang atomic_bug.c -mcpu=pwr6
$ ./a.out 
sc = a
uc = b

$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

$ gcc atomic_bug.c -mcpu=power6
$ ./a.out 
sc = a
uc = c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150316/f5b58e8a/attachment.html>


More information about the llvm-bugs mailing list