[llvm-bugs] [Bug 43893] New: Wrong debug info generated at -O2 (-O0 is correct)

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 3 07:59:53 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=43893

            Bug ID: 43893
           Summary: Wrong debug info generated at -O2 (-O0 is correct)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: qrzhang at gatech.edu
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The expected output from lldb should be -1. However, compiled with "-O2", lldb
outputs -8.



$ clang-trunk -v
clang version 10.0.0 (trunk 375507)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin


$ clang-trunk -g abc.c -O2
$ lldb-trunk -s cmds -batch a.out
(lldb) b 5
Breakpoint 1: where = a.out`main + 7 at abc.c:6:1, address = 0x0000000000400487
(lldb) r
Process 12592 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400487 a.out`main at abc.c:6:1
   3      int b = --a, l_1240 = -8L;
   4      l_1240 = b;
   5      b > 0;  //  optimize_me_not
-> 6    }

Process 12592 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_1240
(int) $0 = -8




$ clang-trunk -g abc.c
$ lldb-trunk -s cmds -batch a.out
(lldb) b 5
Breakpoint 1: where = a.out`main + 42 at abc.c:6:1, address =
0x00000000004004aa
(lldb) r
Process 12562 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004aa a.out`main at abc.c:6:1
   3      int b = --a, l_1240 = -8L;
   4      l_1240 = b;
   5      b > 0;  //  optimize_me_not
-> 6    }

Process 12562 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_1240
(int) $0 = -1


$ cat abc.c
char a;
int main() {
  int b = --a, l_1240 = -8;
  l_1240 = b;
  b > 0;  //  optimize_me_not
}

$ cat cmds
b 5
r
p l_1240
kill
q

-- 
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/20191103/83a3dd06/attachment.html>


More information about the llvm-bugs mailing list