[llvm-bugs] [Bug 46099] New: Wrong line information at O3
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 27 06:29:38 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46099
Bug ID: 46099
Summary: Wrong line information at O3
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: DebugInfo
Assignee: unassignedbugs at nondot.org
Reporter: massarelli at diag.uniroma1.it
CC: ditaliano at apple.com, jdevlieghere at apple.com,
keith.walker at arm.com, llvm-bugs at lists.llvm.org,
paul_robinson at playstation.sony.com
Function b is wrongly hit after exit the for loop.
More precisely the third time the debugger shows to execute b is wrong.
$ cat a.c
static int a[1];
int(b)(c, d) { return (c & (c ^ 7) - d) < 0 ? 0 : c - d; }
short(e)(short c) { return c; }
static int *f() {
short g = 6;
for (; g > 0; g = b(g, 2))
e(g);
*a = g;
return a;
}
int main() {
int i, j, k, print_hash_value;
f();
printf("%X\n");
}
$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
da52aa2c3340d91025c0188175012c476967dc74)
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
$ lldb -v
lldb version 11.0.0
clang revision da52aa2c3340d91025c0188175012c476967dc74
llvm revision da52aa2c3340d91025c0188175012c476967dc74
$ clang -O3 -g -o opt a.c
lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main + 16 [inlined] f + 5 at test.c:13, address =
0x0000000000400510
(lldb) r
Process 118 launched: 'opt' (x86_64)
Process 118 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x0000000000400510 opt`main [inlined] f at test.c:6:10
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
-> 6 for (; g > 0; g = b(g, 2))
7 e(g);
8 *a = g;
9 return a;
(lldb) p b
(int (*)(int, int)) $0 = 0x00000000004004d0 (opt`b at test.c:2:31)
(lldb) p g
(short) $1 = 4
(lldb) s
Process 118 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040051a opt`main [inlined] b(c=4, d=2) at test.c:2:31
1 static int a[1];
-> 2 int(b)(c, d) { return (c & (c ^ 7) - d) < 0 ? 0 : c - d; }
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
6 for (; g > 0; g = b(g, 2))
7 e(g);
(lldb) expr (c & (c ^ 7) - d) < 0 ? 0 : c - d;
(int) $2 = 2
(lldb) s
Process 118 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x0000000000400510 opt`main [inlined] f at test.c:6:10
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
-> 6 for (; g > 0; g = b(g, 2))
7 e(g);
8 *a = g;
9 return a;
(lldb) p g
(short) $3 = 2
(lldb) s
Process 118 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040051a opt`main [inlined] b(c=2, d=2) at test.c:2:31
1 static int a[1];
-> 2 int(b)(c, d) { return (c & (c ^ 7) - d) < 0 ? 0 : c - d; }
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
6 for (; g > 0; g = b(g, 2))
7 e(g);
(lldb) expr (c & (c ^ 7) - d) < 0 ? 0 : c - d;
(int) $4 = 0
(lldb) frame var
(int) c = 2
(int) d = 2
(lldb) s
Process 118 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x0000000000400510 opt`main [inlined] f at test.c:6:10
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
-> 6 for (; g > 0; g = b(g, 2))
7 e(g);
8 *a = g;
9 return a;
(lldb) p g
(short) $5 = 0
(lldb) s
Process 118 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040052f opt`main at test.c:2:23
1 static int a[1];
-> 2 int(b)(c, d) { return (c & (c ^ 7) - d) < 0 ? 0 : c - d; }
3 short(e)(short c) { return c; }
4 static int *f() {
5 short g = 6;
6 for (; g > 0; g = b(g, 2))
7 e(g);
(lldb) di
opt`main:
0x400500 <+0>: movw $0x6, %ax
0x400504 <+4>: movl $0x6, %ecx
0x400509 <+9>: jmp 0x40051a ; <+26> [inlined] b at
test.c:6
0x40050b <+11>: nopl (%rax,%rax)
0x400510 <+16>: movswl %dx, %ecx
0x400513 <+19>: movl %edx, %eax
0x400515 <+21>: testw %cx, %cx
0x400518 <+24>: jle 0x40052f ; <+47> at test.c:2:23
0x40051a <+26>: movl %ecx, %esi
0x40051c <+28>: xorl $0x7, %esi
0x40051f <+31>: addl $-0x2, %esi
0x400522 <+34>: xorl %edx, %edx
0x400524 <+36>: testl %ecx, %esi
0x400526 <+38>: js 0x400510 ; <+16> [inlined] f + 5 at
test.c:13
0x400528 <+40>: addl $-0x2, %eax
0x40052b <+43>: movl %eax, %edx
0x40052d <+45>: jmp 0x400510 ; <+16> [inlined] f + 5 at
test.c:13
-> 0x40052f <+47>: pushq %rax
0x400530 <+48>: movl $0x4005c4, %edi ; imm = 0x4005C4
0x400535 <+53>: xorl %eax, %eax
0x400537 <+55>: callq 0x4003d0 ; symbol stub for: printf
0x40053c <+60>: xorl %eax, %eax
0x40053e <+62>: popq %rcx
0x40053f <+63>: retq
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200527/586ff934/attachment-0001.html>
More information about the llvm-bugs
mailing list