<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 - Recent regression in -O2 -g debugging quality since change to improve handling of dangling debug info"
   href="https://bugs.llvm.org/show_bug.cgi?id=37234">37234</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Recent regression in -O2 -g debugging quality since change to improve handling of dangling debug info
          </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>greg.bedwell@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, bjorn.a.pettersson@ericsson.com, dblaikie@gmail.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using the tool I've developed "DExTer" (Recently presented at EuroLLVM:
<a href="http://llvm.org/devmtg/2018-04/talks.html#Lightning_11">http://llvm.org/devmtg/2018-04/talks.html#Lightning_11</a> - hopefully open-sourced
very soon so that potentially we can set up a bot to track this over time) I've
noticed a recent regression in the optimized debugging experience quality which
I've bisected to "[llvm] r327303 - [SelectionDAG] Improve handling of dangling
debug info".  

Here's my testcase:

// =========================================================
int main() {
        const char* buffer = "aaa";
        unsigned aa = 0;
        while (char c = *buffer++) {
                if (c == 'a')
                        ++aa;  // DexWatch('aa')
        }
        return aa;
}
// DexExpectWatchValue('aa', 0, 1, 2, on_line=7)
// =========================================================

Here are my before and after DExTer traces, which show the steps taken by the
debugger.  In the before case, the first time we step to line 7, evaluating
expression "aa" returns the value 0, the second time the value 1 and the third
time the value 2.  In the after case, "aa" evaluates to 0 each of the three
times we are on line 7.  Stepping is otherwise unchanged.  This should be
easily reproducible using a debugger manually.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BEFORE:
$
C:\work\public-git\upstream-llvm\build-vs2015-native-ninja\bin_BEFORE\clang++.exe
-v
clang version 7.0.0 (trunk 327294) (llvm/trunk 327302)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir:
C:\work\public-git\upstream-llvm\build-vs2015-native-ninja\bin_BEFORE

$ py dexter.py test --builder clang --debugger lldb --cflags="-O2 -g"
--ldflags="-g" -v --tests-dir=tests\investigation
investigation = 0/21 (0.0000)

## BEGIN ##
[1, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "FUNC", {}]
[2, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "0"}]
[3, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[4, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "1"}]
[5, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[6, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "2"}]
[7, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[8, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 10, 1,
"BREAKPOINT", "FORWARD", {}]
.   [9, null, null, 0, 0, "STEP", "UNKNOWN", {}]
## END (9 steps) ##


  test.cpp:7 [aa] [0/21]
    expected encountered values:
      0
      1
      2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AFTER:
$
C:\work\public-git\upstream-llvm\build-vs2015-native-ninja\bin_AFTER\clang++.exe
-v
clang version 7.0.0 (trunk 327294) (llvm/trunk 327303)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir:
C:\work\public-git\upstream-llvm\build-vs2015-native-ninja\bin_AFTER

$ py dexter.py test --builder clang --debugger lldb --cflags="-O2 -g"
--ldflags="-g" -v --tests-dir=tests\investigation
investigation = 12/21 (0.5714)

## BEGIN ##
[1, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "FUNC", {}]
[2, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "0"}]
[3, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[4, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "0"}]
[5, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[6, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 4,
"BREAKPOINT", "FORWARD", {"aa": "0"}]
[7, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 18,
"BREAKPOINT", "BACKWARD", {}]
[8, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 10, 1,
"BREAKPOINT", "FORWARD", {}]
.   [9, null, null, 0, 0, "STEP", "UNKNOWN", {}]
## END (9 steps) ##


  test.cpp:7 [aa] [12/21]
    expected encountered values:
      0

    missing values:
      1 [+6]
      2 [+6]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've seen this behaviour using both LLDB on my Windows PC and with the PS4
debugger (DWARF-based).

Interestingly, with clang-cl.exe and the Visual Studio 2017 debugger, I get
essentially the same before case, with values of 0, 1 and 2 reported.  In the
after case, I get:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ py dexter.py test --builder clang-cl --debugger vs2017 --cflags="/Ox /Zi"
--ldflags="/Zi" -v --tests-dir=tests\investigation
investigation = 9/21 (0.4286)

## BEGIN ##
[1, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 2, 1,
"BREAKPOINT", "FUNC", {}]
[2, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 1,
"BREAKPOINT", "FORWARD", {}]
[3, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 1,
"BREAKPOINT", "FORWARD", {"aa": "Variable is optimized away and not
available."}]
[4, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 1,
"BREAKPOINT", "BACKWARD", {}]
[5, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 1,
"BREAKPOINT", "FORWARD", {"aa": "Variable is optimized away and not
available."}]
[6, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 1,
"BREAKPOINT", "BACKWARD", {}]
[7, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 7, 1,
"BREAKPOINT", "FORWARD", {"aa": "Variable is optimized away and not
available."}]
[8, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 5, 1,
"BREAKPOINT", "BACKWARD", {}]
[9, "main", "c:\\work\\git\\dexter\\tests\\investigation\\test.cpp", 10, 1,
"BREAKPOINT", "FORWARD", {}]
## END (9 steps) ##


  test.cpp:7 [aa] [9/21]
    result optimized away:
      step 3 (Variable is optimized away and not available.) [+3]
      step 5 (Variable is optimized away and not available.) [+3]
      step 7 (Variable is optimized away and not available.) [+3]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

which is better than the DWARF version, but still a step down from what it
reported with the previous commit.</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>