[llvm-bugs] [Bug 40795] New: clang generates wrong debug information at -O3

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 20 19:09:07 PST 2019


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

            Bug ID: 40795
           Summary: clang generates wrong debug information at -O3
           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

It also affects clang 7.0.

The correct output should be "l_34 = -5".

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


$ cat abc.c
volatile int a;
unsigned b = 6;
int main() {
  int l_34 = -5;
  5 >= b && (l_34 = 0, a);
  optimize_me_not();
}


$ cat outer.c
optimize_me_not() {}


$ cat cmds
b 6
r
p l_34
kill
q


<expected output>
$ clang-trunk abc.c outer.c -g
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/absozero/projects/LLDB-testing/reduce/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 76 at abc.c:6:3, address =
0x00000000004004cc
(lldb) r
Process 2483 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004cc a.out`main at abc.c:6:3
   3    int main() {
   4      int l_34 = -5;
   5      5 >= b && (l_34 = 0, a);
-> 6      optimize_me_not();
   7    }

Process 2483 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_34
(int) $0 = -5
(lldb) kill
Process 2483 exited with status = 9 (0x00000009)
(lldb) q



<wrong output at -O3>
$ clang-trunk abc.c outer.c -g -O3
$ lldb-trunk -s cmds -b a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/absozero/projects/LLDB-testing/reduce/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 16 at abc.c:6:3, address =
0x0000000000400490
(lldb) r
Process 3094 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400490 a.out`main at abc.c:6:3
   3    int main() {
   4      int l_34 = -5;
   5      5 >= b && (l_34 = 0, a);
-> 6      optimize_me_not();
   7    }

Process 3094 launched: '/home/absozero/projects/LLDB-testing/reduce/a.out'
(x86_64)
(lldb) p l_34
(int) $0 = 0
(lldb) kill
Process 3094 exited with status = 9 (0x00000009)
(lldb) 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/20190221/1ffd99d4/attachment.html>


More information about the llvm-bugs mailing list