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

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 3 20:12:08 PST 2020


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

            Bug ID: 45095
           Summary: Wrong debug info generated at -O3 (-O0 is correct)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: shuo.d at outlook.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

The expected output from lldb should be -55, but lldb outputs 7 when the
program is compiled with "-O3".




$ clang-trunk -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
534d8866a1d7e6aa86cdf1d71d30c748f7afe59c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64




$ clang-trunk -g abc.c -O3
abc.c:11:8: warning: expression result unused [-Wunused-value]
  p_44 & 4UL;
  ~~~~ ^ ~~~
abc.c:12:1: warning: non-void function does not return a value in all control
paths [-Wreturn-type]
}
^
2 warnings generated.
$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24545/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24545/report/cmds'.
(lldb) b 7
Breakpoint 1: 2 locations.
(lldb) r
Process 7605 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.2
    frame #0: 0x00000000004004ba a.out`main [inlined] e(p_44=7) at abc.c:7:9
   4    unsigned e(p_44) {
   5      for (; a <= 9;) {
   6        p_44 = d(55);
-> 7        if (c) // optimize_me_not0
   8          c ^= 7;
   9        return 0;
   10     }

Process 7605 launched: '/home/sding/LLDB-testing/reduce/24545/report/a.out'
(x86_64)
(lldb) p p_44 
(int) $0 = 7
(lldb) kill
Process 7605 exited with status = 9 (0x00000009) 
(lldb) q




$ clang-trunk -g abc.c -O0
abc.c:11:8: warning: expression result unused [-Wunused-value]
  p_44 & 4UL;
  ~~~~ ^ ~~~
abc.c:12:1: warning: non-void function does not return a value in all control
paths [-Wreturn-type]
}
^
2 warnings generated.
$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24545/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24545/report/cmds'.
(lldb) b 7
Breakpoint 1: where = a.out`e + 44 at abc.c:7:9, address = 0x00000000004004cc
(lldb) r
Process 9725 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004cc a.out`e(p_44=-55) at abc.c:7:9
   4    unsigned e(p_44) {
   5      for (; a <= 9;) {
   6        p_44 = d(55);
-> 7        if (c) // optimize_me_not0
   8          c ^= 7;
   9        return 0;
   10     }

Process 9725 launched: '/home/sding/LLDB-testing/reduce/24545/report/a.out'
(x86_64)
(lldb) p p_44 
(int) $0 = -55
(lldb) kill
Process 9725 exited with status = 9 (0x00000009) 
(lldb) q




$ cat abc.c 
short a;
int c;
char(d)(b) { return -b; }
unsigned e(p_44) {
  for (; a <= 9;) {
    p_44 = d(55);
    if (c) // optimize_me_not0
      c ^= 7;
    return 0;
  }
  p_44 & 4UL;
}
int main() { e(7); }




$ cat cmds 
b 7
r
p p_44 
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/20200304/b02ac1c9/attachment.html>


More information about the llvm-bugs mailing list