<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=40871">40871</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>All
          </td>
        </tr>

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

        <tr>
          <th>Keywords</th>
          <td>wrong-debug
          </td>
        </tr>

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

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>davide@freebsd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>cmtice@google.com, dblaikie@gmail.com, echristo@gmail.com, jeremy.morse.llvm@gmail.com, llvm-bugs@lists.llvm.org, vsk@apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat outer.c
optimize_me_not() {}

$ cat a.c
int main() {
  int k = 0;
  for (; k < 1; k++)
    ;
  optimize_me_not();
}


### -O0

(lldb) r
Process 7046 launched: '/home/davide/LLDB-testing/reduce/a.out' (x86_64)
Process 7046 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004b3 a.out`main at abc.c:5:3
   2      int k = 0;
   3      for (; k < 1; k++)
   4        ;
-> 5      optimize_me_not();
   6    }
(lldb) frame var k
(int) k = 1

### -O3

Current executable set to './a.out' (x86_64).
(lldb) br set -p optimize_me_not
Breakpoint 1: where = a.out`main + 1 at abc.c:5:3, address = 0x0000000000400481
(lldb) r
Process 20271 launched: '/home/davide/LLDB-testing/reduce/a.out' (x86_64)
Process 20271 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400481 a.out`main at abc.c:5:3
   2      int k = 0;
   3      for (; k < 1; k++)
   4        ;
-> 5      optimize_me_not();
   6    }
(lldb) frame var k
(int) k = 0</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>