<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 - [DWARF] call_site/entry_value not guarded properly"
   href="https://bugs.llvm.org/show_bug.cgi?id=46643">46643</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DWARF] call_site/entry_value not guarded properly
          </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>Windows NT
          </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>paul_robinson@playstation.sony.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>My understanding is that DW_TAG_call_site and DW_OP_entry_value 
should be emitted only when the target debugger is GDB or LLDB.
And, when the target DWARF version is less than 5, these should
use the GNU extension codes rather than the standard v5 codes.

It doesn't seem to work that way, at least not completely.
Here's a sample source derived from what's documented in 
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir :

int global;
int foo(int p, int q, int r) {
  global = p + 1;
  asm __volatile("" : : : "edi", "esi", "edx");
  return 123;
}
int bar() {
  foo(12, 13, 14);
  return global;
}

Compiled for Linux, we see the expected stuff.

$ clang -c -gdwarf-5 -O1 t.cpp -target x86_64-pc-linux
$ llvm-dwarfdump -debug-info t.o | grep call_site
0x00000070:     DW_TAG_call_site
0x00000076:       DW_TAG_call_site_parameter
0x0000007b:       DW_TAG_call_site_parameter
0x00000082:       DW_TAG_call_site_parameter
$ llvm-dwarfdump -debug-info t.o | grep entry_value
                     [0x0000000000000003, 0x000000000000000f):
DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
                    DW_AT_call_value    (DW_OP_entry_value(DW_OP_reg4 RSI))
                    DW_AT_call_value    (DW_OP_entry_value(DW_OP_reg1 RDX))
$

Compiled for PS4 (so debugger tuning is "sce") and DWARF v5, we see this:

$ clang -c -gdwarf-5 -O1 t.cpp -target x86_64-scei-ps4
$ llvm-dwarfdump -debug-info t.o | grep call_site
0x0000006e:     DW_TAG_call_site
$ llvm-dwarfdump -debug-info t.o | grep entry_value
                     [0x0000000000000002, 0x0000000000000011):
DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
$

Even for DWARF v4 (the PS4 default) the DW_OP_entry_value remains,
and even uses the v5 standard opcode instead of the v4 GNU extension:

$ clang -c -gdwarf-4 -O1 t.cpp -target x86_64-scei-ps4
$ llvm-dwarfdump -debug-info t.o | grep call_site
$ llvm-dwarfdump -debug-info t.o | grep entry_value
                     [0x0000000000000002, 0x0000000000000011):
DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
$

The conditions for emitting this information need to be tightened up.

(Note: I am looking at supporting call_site/entry_value for the
Sony debugger, but it's unlikely to be in a near-term release, and
in the meantime we'd rather not be emitting DWARF we can't use.)</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>