<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 - [DebugInfo@O2][Dexter] For loop upper bound not tracked correctly by DWARF location list causing misleading watch window values."
   href="https://bugs.llvm.org/show_bug.cgi?id=38997">38997</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DebugInfo@O2][Dexter] For loop upper bound not tracked correctly by DWARF location list causing misleading watch window values.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chackz0x12@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When run with a debugger the test below reports incorrect values for "count". 

The debug info incorrectly tracks count, which moves between 2 locations. The
first is described correctly, but after moving count said its original location
is over written, causing an incorrect value to be reported to the user.

The example was compiled with llvm/clang TOT @ r342534 with options "-O2 -g
-fno-inline" for x86_64 on Ubuntu. Stepping through seems fine, however after
calling simple(ix) things start to go awry.

I also tested this with clang 6.0 release and found the same results.

This test was created to exercise LoopRotate optimisations. I investigated
using the dexter tool at <a href="https://github.com/SNSystems/dexter">https://github.com/SNSystems/dexter</a>. Using opt-bisect
and targeting before and after LoopRotate shows a decline in the quality of the
debugging experience after a loop rotation occurs.

I looked at the IR and didn't see anything major wrong with it, which leads me
to think this is an issue further down the pipeline.

---------------------------------------------------------------------
// test.cpp
#include "simple.h"

int start = 0;

int foo_for(int count) {
  int result = 0;
  for (unsigned long long ix = start; ix != count; ++ix)
    result += simple(ix);
  return result;
}

int main(int argc, const char ** argv) {
  int loopBy = argc + 3;
  return foo_for(loopBy);
}

---------------------------------------------------------------------
// simple.cpp
int simple(int arg) {
  return arg;
}

---------------------------------------------------------------------
// simple.h
int simple(int arg);</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>