<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 -O2 (-O0 is correct)"
   href="https://bugs.llvm.org/show_bug.cgi?id=43893">43893</a>
          </td>
        </tr>

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

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>qrzhang@gatech.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</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>