<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 - 64-bit call site value immediate is truncated"
   href="https://bugs.llvm.org/show_bug.cgi?id=43525">43525</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>64-bit call site value immediate is truncated
          </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>david.stenberg@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling the following test program:

  #include <stdint.h>

  extern void foo(uint64_t);

  int main() {
    foo(UINT64_C(0x1122334455667788));
    return 0;
  }

using:

  clang -O1 -g -Xclang -femit-debug-entry-values -c call.c

the call site value for the 64-bit parameter is truncated to 32 bits:

  0x00000064:       DW_TAG_GNU_call_site_parameter
                      DW_AT_location    (DW_OP_reg5 RDI)
                      DW_AT_GNU_call_site_value (DW_OP_constu 0x55667788)

The truncation happens in collectCallSiteParameters():

  if (auto ParamValue = TII->describeLoadedValue(*I)) {
    if (ParamValue->first->isImm()) {
      unsigned Val = ParamValue->first->getImm(); <---------------
      DbgValueLoc DbgLocVal(ParamValue->second, Val);
      finishCallSiteParam(DbgLocVal, Reg);
  [...]

DbgValueLoc takes a int64_t immediate, so if I change Val to a int64_t, the
correct value is emitted:

  0x00000064:       DW_TAG_GNU_call_site_parameter
                      DW_AT_location    (DW_OP_reg5 RDI)
                      DW_AT_GNU_call_site_value (DW_OP_constu
0x1122334455667788)</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>