<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=40857">40857</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong debug info generated at -O2 (-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>aprantl@apple.com, cmtice@google.com, david.stenberg@ericsson.com, dblaikie@gmail.com, echristo@gmail.com, florian_hahn@apple.com, jeremy.morse.llvm@gmail.com, llvm-bugs@lists.llvm.org, vsk@apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat outer.c
void optimize_me_not() {}

$ cat 7.c
int a[6];
int b;
int main() {
  int i, c = 8;
  for (; c; c--)
    b = b >> 5;
  i = 0;
  for (; i < 7; i++)
    for (; c < 2; c++)
      b = b & 4095 ^ a[b & 255];
  i = 0;
  for (; i < 5; i++)
    ;
  b = b >> 8 ^ 5;
  optimize_me_not();
}

### -O2

(lldb) r
Process 16600 launched: '/home/davide/finished_reducing/a.out' (x86_64)
Process 16600 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004004be a.out`main at 7.c:15:3
   12     for (; i < 5; i++)
   13       ;
   14     b = b >> 8 ^ 5;
-> 15     optimize_me_not();
   16   }
(lldb) frame var
(int) c = 0
(int) i = 0


### -O0

Process 18140 launched: '/home/davide/finished_reducing/a.out' (x86_64)
Process 18140 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400562 a.out`main at 7.c:15:3
   12     for (; i < 5; i++)
   13       ;
   14     b = b >> 8 ^ 5;
-> 15     optimize_me_not();
   16   }
(lldb) frame var
(int) i = 5
(int) c = 2</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>