<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 - inconsistent behaviors at -O2"
   href="https://bugs.llvm.org/show_bug.cgi?id=46049">46049</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>inconsistent behaviors at -O2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yangyibiao@hust.edu.cn
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - inconsistent behaviors at -O2"
   href="https://bugs.llvm.org/show_bug.cgi?id=46049#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - inconsistent behaviors at -O2"
   href="https://bugs.llvm.org/show_bug.cgi?id=46049">bug 46049</a>
              from <span class="vcard"><a class="email" href="mailto:yangyibiao@hust.edu.cn" title="Yibiao Yang (杨已彪) <yangyibiao@hust.edu.cn>"> <span class="fn">Yibiao Yang (杨已彪)</span></a>
</span></b>
        <pre>Created <span class=""><a href="attachment.cgi?id=23536" name="attach_23536" title="the binary">attachment 23536</a> <a href="attachment.cgi?id=23536&action=edit" title="the binary">[details]</a></span>
the binary</pre>
        </div>
        <div>
        <pre>$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ lldb --version
lldb version 11.0.0
  clang revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af
  llvm revision 871beba234a83a2a02da9dedbd59b91a1bfbd7af


$ clang -g -O2 small.c

$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b 6
Breakpoint 1: where = a.out`main + 29 at small.c:6:7, address =
0x000000000040112d
(lldb) r
Process 578366 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 578366 exited with status = 0 (0x00000000) 
(lldb) 


/********************************
As showed above, Line 6 is not hit by lldb when setting breakpoint.
However, it was hit by lldb when using step-i
*********************************/


$ lldb a.out
(lldb) target create "a.out"
Current executable set to '/home/yibiao/Debugger/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main at small.c:4:7, address = 0x0000000000401110
(lldb) r
Process 578410 launched: '/home/yibiao/Debugger/a.out' (x86_64)
Process 578410 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000401110 a.out`main at small.c:4:7
   1    int a, b, d=1;
   2    
   3    int main() {
-> 4      if (d)
   5        a = b==0;
   6      if (a!=1)
   7        return 1;
(lldb) si -c 7
Process 578410 stopped
* thread #1, name = 'a.out', stop reason = instruction step into
    frame #0: 0x0000000000401133 a.out`main at small.c:6:8
   3    int main() {
   4      if (d)
   5        a = b==0;
-> 6      if (a!=1)
   7        return 1;
   8      return 0;
   9    }
(lldb) 




$ cat small.c
int a, b, d=1;

int main() {
  if (d)
    a = b==0;
  if (a!=1)
    return 1;
  return 0;
}</pre>
        </div>
      </p>


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

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>