<html>
    <head>
      <base href="http://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 - Optimized debug info of subregisters is overly narrow & verbose"
   href="http://bugs.llvm.org/show_bug.cgi?id=32269">32269</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Optimized debug info of subregisters is overly narrow & verbose
          </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>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

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

        <tr>
          <th>Assignee</th>
          <td>aprantl@apple.com
          </td>
        </tr>

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>void f1(bool b) {
}

Currently the location description for 'b' (when compiled with optimizations,
-O1 (possibly mem2reg alone) will suffice) is:

  0x55 0x9d 0x01 0x00

  DW_OP_reg5 DW_OP_bit_piece 1 0

Which describes 1 bit at the beginning of reg5.

This causes GCC to print an error when trying to render the variable:

  "error reading variable: access outside bounds of object referenced via
synthetic pointer"

Which seems not unreasonable - the notion that rendering a bool requires access
to all 8 bits of its representation, even if the top 7 bits could be assumed to
be zero. So, yeah, a better debugger might be able to get by - but it seems OK
to try to make this work with GDB as-is.

The fix for this might be in mem2reg, or specifically
llvm::ConvertDEbugDeclareToDebugValue, the special case for ExtendedArgs. If
teh Offset is zero, instead skip the new complex expression and reference the
arg directly.

This gets some of the way, but then LLVM produces:

  DW_OP_reg5 DW_OP_piece 4

Which also seems unnecessary/verbose (& sort of incorrect - describing it as
specifically 4 bytes for a 1 byte thing - though the debugger can choose the
low byte appropriately).

This could be changed in DwarfExpression::setSubRegisterPiece could be a no-op
when the offset is zero? (But this wouldn't be quite right for a case where
that piece was used as part of a larger value, perhaps... (a struct with two
bools, each in a register? Not sure what the right representation for that is))</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>