[llvm-bugs] [Bug 51508] New: Wrong mapping assembly-line at Og
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 17 08:15:57 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51508
Bug ID: 51508
Summary: Wrong mapping assembly-line at Og
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: DebugInfo
Assignee: unassignedbugs at nondot.org
Reporter: artuso at diag.uniroma1.it
CC: jdevlieghere at apple.com, keith.walker at arm.com,
llvm-bugs at lists.llvm.org,
paul_robinson at playstation.sony.com
Comment:
The increment of variable g_64 at line 6 is assigned to wrong assembly
instructions.
Steps to reproduce bug:
root at 14f37d90482b:/home/stepping/output# clang -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
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 at 14f37d90482b:/home/stepping/output# lldb -v
lldb version 14.0.0 (https://github.com/llvm/llvm-project.git revision
957334382cd12ec07b46c0ddfdcc220731f6d80f)
clang revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
llvm revision 957334382cd12ec07b46c0ddfdcc220731f6d80f
root at 9ac1f462aecb:/home/stepping/output# cat a.c
static char b = -1;
int g_64, c;
volatile int d;
char(a)(e, f) { return e - f; }
void func_42() {
++g_64;
c = 0;
for (; c != 3; c = a(c, 1))
d = 9 | b;
b = 0;
}
int main() { func_42(); }
root at 9ac1f462aecb:/home/stepping/output# cat -n a.c
1 static char b = -1;
2 int g_64, c;
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
10 b = 0;
11 }
12 int main() { func_42(); }
root at 9ac1f462aecb:/home/stepping/output# clang -Og -g -Wno-everything -o opt
a.c
root at 9ac1f462aecb:/home/stepping/output# lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/output/opt' (x86_64).
(lldb) b 6
Breakpoint 1: 2 locations.
(lldb) r
Process 36 launched: '/home/stepping/output/opt' (x86_64)
Process 36 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.2
frame #0: 0x00000000004004f0 opt`main [inlined] func_42 at a.c:6:3
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
-> 6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
(lldb) di -l
opt`main:
-> 0x4004f0 <+0>: addl $0x1, 0x200b35(%rip) ; opt.PT_LOAD[1]..bss + 3
0x4004f7 <+7>: cmpb $0x0, 0x200b36(%rip) ; c + 3
0x4004fe <+14>: movl $0x9, %ecx
0x400503 <+19>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
0x400508 <+24>: cmovnel %ecx, %eax
(lldb) si
Process 36 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x00000000004004f7 opt`main [inlined] func_42 at a.c:6:3
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
-> 6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
(lldb) di -l
opt`main:
0x4004f0 <+0>: addl $0x1, 0x200b35(%rip) ; opt.PT_LOAD[1]..bss + 3
-> 0x4004f7 <+7>: cmpb $0x0, 0x200b36(%rip) ; c + 3
0x4004fe <+14>: movl $0x9, %ecx
0x400503 <+19>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
0x400508 <+24>: cmovnel %ecx, %eax
(lldb) si
Process 36 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x00000000004004fe opt`main [inlined] func_42 at a.c:6:3
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
-> 6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
(lldb) di -l
opt`main:
0x4004f0 <+0>: addl $0x1, 0x200b35(%rip) ; opt.PT_LOAD[1]..bss + 3
0x4004f7 <+7>: cmpb $0x0, 0x200b36(%rip) ; c + 3
-> 0x4004fe <+14>: movl $0x9, %ecx
0x400503 <+19>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
0x400508 <+24>: cmovnel %ecx, %eax
(lldb) si
Process 36 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x0000000000400503 opt`main [inlined] func_42 at a.c:6:3
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
-> 6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
(lldb) di -l
opt`main:
0x4004f0 <+0>: addl $0x1, 0x200b35(%rip) ; opt.PT_LOAD[1]..bss + 3
0x4004f7 <+7>: cmpb $0x0, 0x200b36(%rip) ; c + 3
0x4004fe <+14>: movl $0x9, %ecx
-> 0x400503 <+19>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
0x400508 <+24>: cmovnel %ecx, %eax
(lldb) si
Process 36 stopped
* thread #1, name = 'opt', stop reason = instruction step into
frame #0: 0x0000000000400508 opt`main [inlined] func_42 at a.c:6:3
3 volatile int d;
4 char(a)(e, f) { return e - f; }
5 void func_42() {
-> 6 ++g_64;
7 c = 0;
8 for (; c != 3; c = a(c, 1))
9 d = 9 | b;
(lldb) di -l
opt`main:
0x4004f0 <+0>: addl $0x1, 0x200b35(%rip) ; opt.PT_LOAD[1]..bss + 3
0x4004f7 <+7>: cmpb $0x0, 0x200b36(%rip) ; c + 3
0x4004fe <+14>: movl $0x9, %ecx
0x400503 <+19>: movl $0xffffffff, %eax ; imm = 0xFFFFFFFF
-> 0x400508 <+24>: cmovnel %ecx, %eax
--
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/20210817/c073ffd2/attachment.html>
More information about the llvm-bugs
mailing list