[LLVMbugs] [Bug 16521] New: code with volatile struct produces wrong result at -O3 on x86_64-linux-gnu

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 2 00:54:52 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16521

            Bug ID: 16521
           Summary: code with volatile struct produces wrong result at -O3
                    on x86_64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code produces incorrect result when compiled with the current
clang trunk at -O3 on x86_64-linux (in both 32-bit and 64-bit modes). This is a
regression as both clang 3.2 and 3.3 produce correct code. 

$ clang-trunk -v
clang version 3.4 (trunk 185306)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -O2 reduced.c            
$ a.out
0
$ clang-trunk -O3 reduced.c
$ a.out
1
$ clang-3.3 -O3 reduced.c
$ a.out
0
$ clang-3.2 -O3 reduced.c
$ a.out
0


------------------------------------

int printf (const char *, ...);

int a, b, c, d, e = 1; 

struct S
{
  int f;
};

volatile struct S s;

void foo (int *p)
{
  int i;
  for (i = 0; i < 4; i++) {
    int t[2] = {0, 0};
    for (; b < 2; b++) {
      d = 0;
      for (; d >= 0; d--)
    c = 0;
      for (; c < 7; c++)
    t[1] ^= 1;
    }
    if (t[1]) {
      s; 
      *p = e;
    }
  }
}

int main ()
{
  foo (&a);
  printf ("%d\n", a);
  return 0;
}

-- 
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/20130702/240fdaaa/attachment.html>


More information about the llvm-bugs mailing list