<html>
    <head>
      <base href="http://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 --- - DW_AT_frame_base with frame register isn't encoded with DW_OP_fbreg"
   href="http://llvm.org/bugs/show_bug.cgi?id=22762">22762</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DW_AT_frame_base with frame register isn't encoded with DW_OP_fbreg
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hjl.tools@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, michael.m.kuperstein@intel.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13978" name="attach_13978" title="A testcase">attachment 13978</a> <a href="attachment.cgi?id=13978&action=edit" title="A testcase">[details]</a></span>
A testcase

DwarfExpression::AddMachineRegIndirect in DwarfExpression.cpp has

bool DwarfExpression::AddMachineRegIndirect(unsigned MachineReg, int Offset) {
  int DwarfReg = getTRI()->getDwarfRegNum(MachineReg, false);
  if (DwarfReg < 0)
    return false;

  if (isFrameRegister(MachineReg)) {
    // If variable offset is based in frame register then use fbreg.
    EmitOp(dwarf::DW_OP_fbreg);
    EmitSigned(Offset);
  } else {
    AddRegIndirect(DwarfReg, Offset);
  }
  return true;
}

X32 uses EBP as frame register and EBP doesn't map to a DWARF register
number.  But frame register is special, which should be mapped to
DW_OP_fbreg, regardless its DWARF register number.  The check of
DwarfReg < 0 should be moved after if (isFrameRegister(MachineReg))
check.

./llc -mtriple=x86_64-pc-linux-gnux32 -filetype=obj -o x.o x.ll
readelf -w x.o | grep DW_AT_frame_base
    <2b>   DW_AT_frame_base  : 3 byte block: 56 93 4     (DW_OP_reg6 (rbp);
DW_OP_piece: 4)
    DW_AT_frame_base   DW_FORM_exprloc</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>