<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 - Unnecessary narrowing of register reference in DW_AT_location for int parameter"
   href="http://bugs.llvm.org/show_bug.cgi?id=32288">32288</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unnecessary narrowing of register reference in DW_AT_location for int parameter
          </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>unassignedbugs@nondot.org
          </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>Created <span class=""><a href="attachment.cgi?id=18099" name="attach_18099" title="repro IR">attachment 18099</a> <a href="attachment.cgi?id=18099&action=edit" title="repro IR">[details]</a></span>
repro IR

Given:

  void f(int i) { }

(which produces the attached LLVM IR)

The DWARF generated by LLVM includes this location:

  0x55 0x93 0x04
  DW_OP_reg5 DW_OP_piece(4)

When GCC's DWARF is simply 0x55 (DW_OP_reg5) without the DW_OP_piece. I believe
it's reasonable to assume the DWARF consumer knows which part of a register
logically holds the value (low bytes, high bytes, how many bytes, etc) for a
primitive value like an integer.

If something fancy is going on, like the register only contains part of an
object (eg: struct foo { int x, y, z; }; gets {reg5, piece(8), reg4, piece(4)}
which is probably important ({reg5, reg4} seems inadequate) - interestingly,
GCC uses fbreg (insufficient optimization?) even at -O3)

PR33269 has some related work.

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... as in the 'foo'
example above)</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>