<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 - DWP_OP(_GNU)_entry_value not used correctly to display clobbered parameter value (in dwarf4 and dwarf5)"
   href="https://bugs.llvm.org/show_bug.cgi?id=45653">45653</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DWP_OP(_GNU)_entry_value not used correctly to display clobbered parameter value (in dwarf4 and dwarf5)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

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

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The code below when compiled with -O3 produces DW_TAG_GNU_call_site +
DW_OP_GNU_entry_value (dwarf4) / DW_TAG_call_site  + DW_OP_entry_value (dwarf5)
debug information. LLDB should use that to show the parameter value even when
the corresponding register was clobbered.

However, this doesn't work neither in dwarf4 nor dwarf5:
- In dwarf4, lldb does show a value for the parameter, but shows the clobbered
value.
- In dwarf5, lldb claims the parameter value as "<unavailable>"

Code
----

__attribute__((noinline))
int fn1 (int z) {
      int l = z * z;
      return l + 1;
}

int main(void) {
      return fn1(2);
}


DWARF4 (clang -O3 -g)
---

0x0000002a:   DW_TAG_subprogram
                DW_AT_name      ("fn1")

0x00000047:     DW_TAG_formal_parameter
                  DW_AT_location        (0x00000000:
                     [0x0000000000401110, 0x0000000000401113): DW_OP_reg5 RDI
                     [0x0000000000401113, 0x0000000000401117):
DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
                  DW_AT_name    ("z")

0x00000066:   DW_TAG_subprogram
                DW_AT_name      ("main")

0x0000007f:     DW_TAG_GNU_call_site

0x0000008c:       DW_TAG_GNU_call_site_parameter
                    DW_AT_location      (DW_OP_reg5 RDI)
                    DW_AT_GNU_call_site_value   (DW_OP_lit2)

Process 55759 stopped
* thread #1, name = 'test_llvm', stop reason = step in
    frame #0: 0x0000000000401113 test_llvm`fn1(z=4) at test.cc:4:16
   1    __attribute__((noinline))
   2    int fn1 (int z) {
   3          int l = z * z;
-> 4          return l + 1;
   5    }
   6
   7    int main(void) {


DWARF5 (clang -O3 -gdwarf-5)
----

0x00000027:   DW_TAG_subprogram
                DW_AT_name      ("fn1")

0x00000037:     DW_TAG_formal_parameter
                  DW_AT_location        (indexed (0x0) loclist = 0x00000014:
                     [0x0000000000401110, 0x0000000000401113): DW_OP_reg5 RDI
                     [0x0000000000401113, 0x0000000000401117):
DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
                  DW_AT_name    ("z")

0x0000004a:   DW_TAG_subprogram
                DW_AT_name      ("main")

0x00000059:     DW_TAG_call_site

0x0000005f:       DW_TAG_call_site_parameter
                    DW_AT_location      (DW_OP_reg5 RDI)
                    DW_AT_call_value    (DW_OP_lit2)

Process 50149 stopped
* thread #1, name = 'test_llvm', stop reason = step in
    frame #0: 0x0000000000401113 test_llvm`fn1(z=<unavailable>) at test.cc:4:16
   1    __attribute__((noinline))
   2    int fn1 (int z) {
   3          int l = z * z;
-> 4          return l + 1;
   5    }
   6
   7    int main(void) {</pre>
        </div>
      </p>


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

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>