<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] LiveDebugValues: Spill restores don't check location discriminator"
   href="https://bugs.llvm.org/show_bug.cgi?id=43058">43058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DebugInfo@O2] LiveDebugValues: Spill restores don't check location discriminator
          </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>Linux
          </td>
        </tr>

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

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

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

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

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jeremy.morse.llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, chackz0x12@gmail.com, greg.bedwell@sony.com, llvm-bugs@lists.llvm.org, orlando.hyams@sony.com, paul.robinson@am.sony.com, stephen.tozer@sony.com, vsk@apple.com
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>31268
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Carrot Wei writes in the llvm-commits discussion for r368339, here:
<a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190819/685357.html">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190819/685357.html</a>

  There are following code in
  function LiveDebugValues::transferSpillOrRestoreInst,

   854     } else if (TKind == TransferKind::TransferRestore &&
   855                VarLocIDs[ID].Loc.SpillLocation == *Loc) {
   856       LLVM_DEBUG(dbgs() << "Restoring Register " << printReg(Reg,
  TRI) << '('
   857                         << VarLocIDs[ID].Var.getVar()->getName() <<
")\n");

  There is no checking of VarLocIDs[ID].Kind before the usage of
  VarLocIDs[ID].Loc.SpillLocation, is this another bug?

This is certainly a bug, and one we should fix: the VarLoc discriminator should
be checked to ensure the "Loc" union contains data of the expected type. As
it's a one-liner and obviously broken, I was just going to drop a commit in
that fixed this; however comparing a clang-3.4 build with/without that change
based on r369117, the "scope bytes covered" statistic from `llvm-dwarfdump
--statistics` jumps from 46% to 54%, which is too good to be true.

My hunch is that this bug is masking the effects of <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [DebugInfo@O2] LiveDebugValues misses stack restores, creates immortal variable locations"
   href="show_bug.cgi?id=42772">bug 42772</a>, which would
explain the sudden increase in code coverage; only 15% confidence though.
Additional investigation of what effect this change has is needed IMO.</pre>
        </div>
      </p>

        <div id="referenced">
          <hr style="border: 1px dashed #969696">
          <b>Referenced Bugs:</b>
          <ul>
              <li>
                [<a class="bz_bug_link 
          bz_status_CONFIRMED "
   title="CONFIRMED - Umbrella: debug info for optimized code"
   href="https://bugs.llvm.org/show_bug.cgi?id=31268">Bug 31268</a>] Umbrella: debug info for optimized code
              </li>
          </ul>
        </div>
        <br>

      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>