You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The expected output from lldb should be 5. However, compiled with "-O3", lldb outputs 0.
$ clang-trunk -v
clang version 10.0.0 (trunk 375507)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64
$ clang-trunk -g abc.c -O3
abc.c:6:13: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
void f(g) { printf("%X\n", g); }
^
abc.c:6:13: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30972/report/cmds'.
(lldb) b 25
Breakpoint 1: where = a.out`main + 781 at abc.c:25:7, address = 0x000000000040083d
(lldb) r
Process 21519 stopped
thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000000000040083d a.out`main at abc.c:25:7
22 for (; i < 5; i++)
23 h(e[i]);
24 h(1);
-> 25 f(b ^ 5); // optimize_me_not0
26 }
Process 21519 launched: '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64)
(lldb) p i
(int) $0 = 0
$ clang-trunk -g abc.c -O0
abc.c:6:13: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
void f(g) { printf("%X\n", g); }
^
abc.c:6:13: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30972/report/cmds'.
(lldb) b 25
Breakpoint 1: where = a.out`main + 164 at abc.c:25:5, address = 0x0000000000400634
(lldb) r
Process 29588 stopped
thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400634 a.out`main at abc.c:25:5
22 for (; i < 5; i++)
23 h(e[i]);
24 h(1);
-> 25 f(b ^ 5); // optimize_me_not0
26 }
Process 29588 launched: '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64)
(lldb) p i
(int) $0 = 5
$ cat abc.c
int a[56];
int b;
short c;
static int d;
static int e[] = {4, 0, 4, 0, 4};
void f(g) { printf("%X\n", g); }
void h(g) {
b = b & 4095 ^ a[(b ^ g) & 255];
b = b & 4095 ^ a[(b ^ 8) & 255];
b = b & 4095 ^ a[(b ^ 6) & 5];
}
int main() {
int i, j;
i = 0;
h(c);
for (; i < 3; i++) {
j = 0;
for (; j < 2; j++)
h(d);
}
i = 0;
for (; i < 5; i++)
h(e[i]);
h(1);
f(b ^ 5); // optimize_me_not0
}
$ cat cmds
b 25
r
p i
kill
q
The text was updated successfully, but these errors were encountered:
Much like bug 43949 this reproducer has some exciting stepping behaviour, including two gratuitous backwards steps (23->15, 24->19)
Temporary breakpoint 2, main () at abc.c:15
15 h(c);
(gdb) n
19 h(d);
(gdb) n
23 h(e[i]);
(gdb) n
15 h(c);
(gdb) n
24 h(1);
(gdb) n
19 h(d);
(gdb) n
25 f(b ^ 5); // optimize_me_not0
(gdb)
Much like bug 43949, this too appears to be the fault of the machine instruction scheduler. The location list tail:
clearly has some zeros in the wrong place (the entire program has been inlined & unrolled). The re-ordering appears to happen in machine instruction scheduler.
Technically this problem is a duplicate of 43949, but I think the stepping behaviour is worth looking at as well.
Extended Description
The expected output from lldb should be 5. However, compiled with "-O3", lldb outputs 0.
$ clang-trunk -v
clang version 10.0.0 (trunk 375507)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64
$ clang-trunk -g abc.c -O3
abc.c:6:13: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
void f(g) { printf("%X\n", g); }
^
abc.c:6:13: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30972/report/cmds'.
(lldb) b 25
Breakpoint 1: where = a.out`main + 781 at abc.c:25:7, address = 0x000000000040083d
(lldb) r
Process 21519 stopped
frame #0: 0x000000000040083d a.out`main at abc.c:25:7
22 for (; i < 5; i++)
23 h(e[i]);
24 h(1);
-> 25 f(b ^ 5); // optimize_me_not0
26 }
Process 21519 launched: '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64)
(lldb) p i
(int) $0 = 0
$ clang-trunk -g abc.c -O0
abc.c:6:13: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
void f(g) { printf("%X\n", g); }
^
abc.c:6:13: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/30972/report/cmds'.
(lldb) b 25
Breakpoint 1: where = a.out`main + 164 at abc.c:25:5, address = 0x0000000000400634
(lldb) r
Process 29588 stopped
frame #0: 0x0000000000400634 a.out`main at abc.c:25:5
22 for (; i < 5; i++)
23 h(e[i]);
24 h(1);
-> 25 f(b ^ 5); // optimize_me_not0
26 }
Process 29588 launched: '/home/sding/LLDB-testing/reduce/30972/report/a.out' (x86_64)
(lldb) p i
(int) $0 = 5
$ cat abc.c
int a[56];
int b;
short c;
static int d;
static int e[] = {4, 0, 4, 0, 4};
void f(g) { printf("%X\n", g); }
void h(g) {
b = b & 4095 ^ a[(b ^ g) & 255];
b = b & 4095 ^ a[(b ^ 8) & 255];
b = b & 4095 ^ a[(b ^ 6) & 5];
}
int main() {
int i, j;
i = 0;
h(c);
for (; i < 3; i++) {
j = 0;
for (; j < 2; j++)
h(d);
}
i = 0;
for (; i < 5; i++)
h(e[i]);
h(1);
f(b ^ 5); // optimize_me_not0
}
$ cat cmds
b 25
r
p i
kill
q
The text was updated successfully, but these errors were encountered: