Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

likely wrong code bug: one of two indirect reassignments fails at O1 #13010

Closed Quuxplusone closed 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR12901
Status RESOLVED FIXED
Importance P enhancement
Reported by John Regehr (regehr@cs.utah.edu)
Reported on 2012-05-20 22:56:51 -0700
Last modified on 2012-08-13 18:09:27 -0700
Version trunk
Hardware PC Linux
CC atrick@apple.com, chenyang@cs.utah.edu, flash@pobox.com, llvm-bugs@lists.llvm.org, nadav.rotem@me.com, rafael@espindo.la
Fixed by commit(s)
Attachments t.ll (4364 bytes, application/octet-stream)
small.c (1325 bytes, text/plain)
Blocks
Blocked by
See also
No idea what's going on here but I think the code is legit and that LLVM should
not be changing its answer.

[regehr@dyson r55]$ clang -O0 small.c ; ./a.out
1
[regehr@dyson r55]$ clang -O1 small.c ; ./a.out
0
[regehr@dyson r55]$ current-gcc -O3 small.c ; ./a.out
1
[regehr@dyson r55]$ cat small.c
int printf (const char *, ...);
int a, b = 1, c, e, f, h, i, j;
int *d = &c, *g = &c;

void fn1 (int *p1)
{
    *p1 = *d;
}

void fn2 (int *p1)
{
    f = *p1;
    *g = f;
}

int main ()
{
    int *k = &b, *l = &b;
    h = 1;
    for (; h; h--)
        for (; j <= 0; j++)
        {
            int **m = &l;
            for (; i <= 0; i++)
                *l = 0;
            *k ^= 1;
            *m = 0;
        }
    e = b;
    fn2 (&e);
    fn1 (&a);
    printf ("%d\n", a);
    return 0;
}
[regehr@dyson r55]$ clang -v
clang version 3.2 (trunk 157145)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Quuxplusone commented 12 years ago

Attached t.ll (4364 bytes, application/octet-stream): bitcode test case

Quuxplusone commented 12 years ago

Attached small.c (1325 bytes, text/plain): Annotated C source

Quuxplusone commented 12 years ago

Cloned to rdar://problem/11872059 [PR12901] likely wrong code bug: one of two indirect reassignments fails at O1

Quuxplusone commented 12 years ago

Fixed in r161803.