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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to