<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Inconsistent variable value and assembly mapping at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=51648">51648</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Inconsistent variable value and assembly mapping at Og
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>artuso@diag.uniroma1.it
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr></table>
<p>
<div>
<pre>Comment:
The code exhibits an odd stepping behaviour with inconsistent values of
variables.
The code steps on line 11, 13, line 0 and it goes back to line 12.
After stepping on line 13, the debuggers steps on "movl $0x1, 0x200aec(%rip)"
which set g_3 to 1. Then the debugger steps back at line 12. However, if g_3 is
equal to one, we should have exited the for cycle at line 6 and so we could not
be at line 12 with g_3 equal to 1.
If we print g_3 at line 12 we can see that is equal to 1, this is also
inconsistent with the value of l_5[4] that is, correctly, equal to 0. But has
been assigned to g_3 at line 11.
Finally, when stepping at line 12 the assembly instruction shown is movb $0x1,
0x200ae3(%rip), which is inconsistent with the source code (the value that
should be moved should be 0 and not 1, this is probably related to the fact
that g_3 is equal to 1).
Steps to reproduce bug:
root@b82d9377034e:/home/stepping/output# clang -v
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
957334382cd12ec07b46c0ddfdcc220731f6d80f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
root@b82d9377034e:/home/stepping/output# lldb -v
lldb version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a> revision
957334382cd12ec07b46c0ddfdcc220731f6d80f)
clang revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
llvm revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
root@b82d9377034e:/home/stepping/output# cat a.c
int a, g_3, b, d;
static int g_8 = 9;
char c;
char func_1() {
g_3 = 0;
for (; g_3 <= 0; g_3++) {
int l_5[9];
d = 0;
for (; d < 9; d++)
l_5[d] = 0;
l_5[4] = g_3;
g_8 = l_5[4];
if (c) {
b = l_5;
return;
}
}
}
int main() {
func_1();
a = g_8;
}
root@b82d9377034e:/home/stepping/output# cat -n a.c
1 int a, g_3, b, d;
2 static int g_8 = 9;
3 char c;
4 char func_1() {
5 g_3 = 0;
6 for (; g_3 <= 0; g_3++) {
7 int l_5[9];
8 d = 0;
9 for (; d < 9; d++)
10 l_5[d] = 0;
11 l_5[4] = g_3;
12 g_8 = l_5[4];
13 if (c) {
14 b = l_5;
15 return;
16 }
17 }
18 }
19 int main() {
20 func_1();
21 a = g_8;
22 }
root@b82d9377034e:/home/stepping/output# clang -Og -g -Wno-everything -o opt
a.c
root@b82d9377034e:/home/stepping/output# lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main + 7 [inlined] func_1 at a.c:11:12, address =
0x00000000004004f7
(lldb) r
Process 128 launched: '/home/stepping/output/opt' (x86_64)
Process 128 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004f7 opt`main at a.c:11:12
8 d = 0;
9 for (; d < 9; d++)
10 l_5[d] = 0;
-> 11 l_5[4] = g_3;
12 g_8 = l_5[4];
13 if (c) {
14 b = l_5;
(lldb) s
Process 128 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040050c opt`main at a.c:13:9
10 l_5[d] = 0;
11 l_5[4] = g_3;
12 g_8 = l_5[4];
-> 13 if (c) {
14 b = l_5;
15 return;
16 }
(lldb) si
Process 128 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x0000000000400536 opt`main [inlined] func_1 at a.c:0
1 int a, g_3, b, d;
2 static int g_8 = 9;
3 char c;
4 char func_1() {
5 g_3 = 0;
6 for (; g_3 <= 0; g_3++) {
7 int l_5[9];
(lldb) di -l
opt`main:
-> 0x400536 <+70>: movl $0x1, 0x200aec(%rip) ; completed.7698
0x400540 <+80>: movl $0x9, 0x200ae6(%rip) ; g_3
(lldb) p g_3
(int) $0 = 0
(lldb) si
Process 128 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x0000000000400540 opt`main at a.c:0
1 int a, g_3, b, d;
2 static int g_8 = 9;
3 char c;
4 char func_1() {
5 g_3 = 0;
6 for (; g_3 <= 0; g_3++) {
7 int l_5[9];
(lldb) p g_3
(int) $1 = 1
(lldb) di -l
opt`main:
0x400536 <+70>: movl $0x1, 0x200aec(%rip) ; completed.7698
-> 0x400540 <+80>: movl $0x9, 0x200ae6(%rip) ; g_3
(lldb) p d
(int) $2 = 0
(lldb) si
Process 128 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x000000000040054a opt`main at a.c:12:9
9 for (; d < 9; d++)
10 l_5[d] = 0;
11 l_5[4] = g_3;
-> 12 g_8 = l_5[4];
13 if (c) {
14 b = l_5;
15 return;
(lldb) di -l
opt`main:
-> 0x40054a <+90>: movb $0x1, 0x200ae3(%rip) ; d + 3
(lldb) p d
(int) $3 = 9
(lldb) p l_5
(int [9]) $5 = ([0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0,
[7] = 0, [8] = 0)
(lldb) p g_8
(int) $6 = 9
(lldb) si
Process 128 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x0000000000400551 opt`main at a.c:21:7
18 }
19 int main() {
20 func_1();
-> 21 a = g_8;
22 }
(lldb) p g_8
(int) $7 = 0</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>