[llvm-bugs] [Bug 42627] New: Incorrect type for 'this' in debuginfo for non-virtual thunks

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 15 19:47:08 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42627

            Bug ID: 42627
           Summary: Incorrect type for 'this' in debuginfo for non-virtual
                    thunks
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: roc at ocallahan.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 22245
  --> https://bugs.llvm.org/attachment.cgi?id=22245&action=edit
testcase

Compile attached testcase with
clang++ -g -o /tmp/test /tmp/test.cc

Then dwarfdump -i /tmp/test shows, in part:

< 1><0x000000cc>    DW_TAG_class_type
                      DW_AT_containing_type       <0x0000010e>
                      DW_AT_calling_convention    DW_CC_pass_by_reference
                      DW_AT_name                  Derived
                      DW_AT_byte_size             0x00000018
                      DW_AT_decl_file             0x00000001
/home/roc/tmp/test.cc
                      DW_AT_decl_line             0x00000010
...
< 1><0x0000021c>    DW_TAG_subprogram
                      DW_AT_low_pc                0x004012f0
                      DW_AT_high_pc               <offset-from-lowpc>22
                      DW_AT_frame_base            len 0x0001: 56: DW_OP_reg6
                      DW_AT_object_pointer        <0x00000235>
                      DW_AT_linkage_name          _ZThn8_N7Derived4funcEv
                      DW_AT_decl_file             0x00000001
/home/roc/tmp/test.cc
                      DW_AT_decl_line             0x00000012
                      DW_AT_artificial            yes(1)
                      DW_AT_external              yes(1)
< 2><0x00000235>      DW_TAG_formal_parameter
                        DW_AT_location              len 0x0002: 9178:
DW_OP_fbreg -8
                        DW_AT_name                  this
                        DW_AT_type                  <0x00000242>
                        DW_AT_artificial            yes(1)
< 1><0x00000242>    DW_TAG_pointer_type
                      DW_AT_type                  <0x000000cc>

In particular 'this' is given type 'Derived', but in fact, in the thunk, it is
never a pointer to `Derived`, only `Base`. Here's the disasssembled thunk:

Dump of assembler code for function _ZThn8_N7Derived4funcEv:
=> 0x00000000004012f0 <+0>:     push   %rbp
   0x00000000004012f1 <+1>:     mov    %rsp,%rbp
   0x00000000004012f4 <+4>:     mov    %rdi,-0x8(%rbp)
   0x00000000004012f8 <+8>:     mov    -0x8(%rbp),%rdi
   0x00000000004012fc <+12>:    add    $0xfffffffffffffff8,%rdi
   0x0000000000401300 <+16>:    pop    %rbp
   0x0000000000401301 <+17>:    jmpq   0x4012c0 <Derived::func()>

`DW_OP_fbreg -8` is always the incoming parameter value, which points to
`Base`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190716/87b0d32d/attachment.html>


More information about the llvm-bugs mailing list