<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - LiveDebugValues missing propagation of debug info across bb boundaries"
   href="https://llvm.org/bugs/show_bug.cgi?id=27629">27629</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LiveDebugValues missing propagation of debug info across bb boundaries
          </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>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>warren_ristow@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The test case listed at the end of this comment shows a degradation in
debug-info quality when compiled at '-O1 -g', when moving from llvm 3.7 to
llvm 3.8.

When using llvm 3.7, the variable 'ptr' can be examined at the two lines
with the comment "set a breakpoint here", but with llvm 3.8, 'ptr' is no
longer visible on those lines, because the needed DBG_VALUE instructions
haven't been inserted by the LiveDebugValues pass.  (Also tested with modern
TOT, r268454, and the behavior is the same as llvm 3.8.)

In looking at it, I believe the problem is a bug in the data flow analysis
done in the (relatively new) LiveDebugValues pass.

Note that when the LiveDebugValues pass was first committed (r255759), the
debug-quality for 'ptr' was still "good" at '-O1 -g'.  The poor visibility
of 'ptr' first appeared in r256188, when a change was made to the related
LiveDebugVariables analysis.  Regarding r256188, this was to fix the issue
of <a class="bz_bug_link 
          bz_status_CLOSED  bz_closed"
   title="CLOSED FIXED - LiveDebugVariables propagates constant values without joining at bb boundaries"
   href="show_bug.cgi?id=24563">bug 24563</a> (LiveDebugVariables unconditionally propagates all DBG_VALUEs).
In that change, it was noted that with the recent data flow analysis of the
LiveDebugValues pass (which runs after LiveDebugVariables), the propagation
being done by LiveDebugVariables was redundant, and could be removed. I
believe that's the correct approach, but I think there was a latent bug in
the data flow analysis of LiveDebugValues that was exposed when that
propagation was removed from LiveDebugVariables, causing the problem
described here.

/* ============================== "test.c" ============================== */
/* Compile as:
 *
 *      clang -c -O1 -g test.c
 *
 * and check the visiblilty of 'ptr' in llvm3.7 vs llvm3.8 at lines with
 * the 'set a breakpoint here' comment.
 */
struct A {
  int i;
  float f;
};

extern void foo(struct A *ptr, int lim);
extern int use(int i);

void foo(struct A *ptr, int lim)
{
  int i;
  for (i = 0; i < lim; ++i) {
    if (i > lim/2) {
      ptr->i += 2*use(i);       // set a breakpoint here, and examine 'ptr'
    } else {
      ptr->i += use(i);         // set a breakpoint here, and examine 'ptr'
    }
  }
}
/* ====================================================================== */</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>