<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Wrong debug info generated at -O3 (-O0 is correct)"
   href="https://bugs.llvm.org/show_bug.cgi?id=45080">45080</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong debug info generated at -O3 (-O0 is correct)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>shuo.d@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The expected output from lldb should be 0, but lldb outputs -7 when the program
is compiled with "-O3".



$ clang-trunk -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
daab6ad58d4b2c90126efacb836c9286fd85031f)
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
$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24113/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24113/report/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 5 at abc.c:6:5, address = 0x0000000000400485
(lldb) r
Process 18367 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400485 a.out`main at abc.c:6:5
   3    int main() {
   4      int l_2864 = -7L;
   5      l_2864 = b;
-> 6      a = &l_2864; // optimize_me_not0
   7    }

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




$ clang-trunk -g abc.c -O0
$ lldb-trunk -s cmds -b a.out 
(lldb) target create "a.out"
Current executable set to '/home/sding/LLDB-testing/reduce/24113/report/a.out'
(x86_64).
(lldb) command source -s 0 'cmds'
Executing commands in '/home/sding/LLDB-testing/reduce/24113/report/cmds'.
(lldb) b 6
Breakpoint 1: where = a.out`main + 24 at abc.c:6:5, address =
0x0000000000400498
(lldb) r
Process 21823 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400498 a.out`main at abc.c:6:5
   3    int main() {
   4      int l_2864 = -7L;
   5      l_2864 = b;
-> 6      a = &l_2864; // optimize_me_not0
   7    }

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




$ cat abc.c 
int *a;
char b;
int main() {
  int l_2864 = -7L;
  l_2864 = b;
  a = &l_2864; // optimize_me_not0
}




$ cat cmds 
b 6
r
p l_2864 
kill
q</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>