<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 - Odd stepping behaviour at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=47274">47274</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Odd stepping behaviour 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>massarelli@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>Odd stepping behavior. 'func_2' calls function 'b' at line 17. After return
from function 'b' line 14 is hit.
$ cat -n a.c
1 int a, c ;
2 int d[1] ;
3 void __assert_fail ()
4 ;
5 short
6 b(e )
7 {
8 return
9 e >> a
10 ;
11 }
12 void func_2()
13 {
14 int *l_368 = d;
15 int f = 1;
16 int g = c = 0;
17 if (b(3))
18 (*l_368) = 6;
19 else
20 for (; g < 10; g++)
21 l_368 = &f;
22 l_368 == &f || d[0] ? (void) 0 : __assert_fail ();
23 }
24 int main ()
25 {
26 func_2();
27 }
$ cat a.c
int a, c ;
int d[1] ;
void __assert_fail ()
;
short
b(e )
{
return
e >> a
;
}
void func_2()
{
int *l_368 = d;
int f = 1;
int g = c = 0;
if (b(3))
(*l_368) = 6;
else
for (; g < 10; g++)
l_368 = &f;
l_368 == &f || d[0] ? (void) 0 : __assert_fail ();
}
int main ()
{
func_2();
}
$ clang -v
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
bc8be3054067ac822fc6d9f4f8e64c841f530f16)
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
$ clang -Og -g -o opt a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b func_2
Breakpoint 1: where = opt`func_2 + 1 at a.c:15:9, address = 0x00000000004004f1
(lldb) r
Process 225 launched: 'opt' (x86_64)
Process 225 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004f1 opt`func_2 at a.c:15:9
12 void func_2()
13 {
14 int *l_368 = d;
-> 15 int f = 1;
16 int g = c = 0;
17 if (b(3))
18 (*l_368) = 6;
(lldb) s
Process 225 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004f9 opt`func_2 at a.c:16:15
13 {
14 int *l_368 = d;
15 int f = 1;
-> 16 int g = c = 0;
17 if (b(3))
18 (*l_368) = 6;
19 else
(lldb) s
Process 225 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400503 opt`func_2 at a.c:17:9
14 int *l_368 = d;
15 int f = 1;
16 int g = c = 0;
-> 17 if (b(3))
18 (*l_368) = 6;
19 else
20 for (; g < 10; g++)
(lldb) s
Process 225 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004e2 opt`b(e=3) at a.c:9:10
6 b(e )
7 {
8 return
-> 9 e >> a
10 ;
11 }
12 void func_2()
(lldb) s
Process 225 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004ea opt`b(e=<unavailable>) at a.c:8:3
5 short
6 b(e )
7 {
-> 8 return
9 e >> a
10 ;
11 }
(lldb) s
Process 225 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400512 opt`func_2 at a.c:14:10
11 }
12 void func_2()
13 {
-> 14 int *l_368 = d;
15 int f = 1;
16 int g = c = 0;
17 if (b(3))
(lldb) bt
* thread #1, name = 'opt', stop reason = step in
* frame #0: 0x0000000000400512 opt`func_2 at a.c:14:10
frame #1: 0x0000000000400546 opt`main at a.c:26:12
frame #2: 0x00007ffff7a05b97 libc.so.6`__libc_start_main + 231
frame #3: 0x000000000040041a opt`_start + 42
(lldb) di
opt`func_2:
0x4004f0 <+0>: pushq %rax
0x4004f1 <+1>: movl $0x1, 0x4(%rsp)
0x4004f9 <+9>: movl $0x0, 0x200b39(%rip) ; d
0x400503 <+19>: movl $0x3, %edi
0x400508 <+24>: callq 0x4004e0 ; b at a.c:7
0x40050d <+29>: leaq 0x4(%rsp), %rcx
-> 0x400512 <+34>: movq %rcx, %rdx
0x400515 <+37>: testw %ax, %ax
0x400518 <+40>: je 0x400529 ; <+57> at a.c:22:11
0x40051a <+42>: movl $0x6, 0x200b14(%rip) ; a
0x400524 <+52>: movl $0x601038, %edx ; imm = 0x601038
0x400529 <+57>: cmpq %rcx, %rdx
0x40052c <+60>: je 0x40053e ; <+78> at a.c:23:1
0x40052e <+62>: cmpl $0x0, 0x200b03(%rip) ; a + 3
0x400535 <+69>: jne 0x40053e ; <+78> at a.c:23:1
0x400537 <+71>: xorl %eax, %eax
0x400539 <+73>: callq 0x4003e0 ; symbol stub for:
__assert_fail
0x40053e <+78>: popq %rax
0x40053f <+79>: retq
Looking at the assembly code it seems that it is actually executing line 21.</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>