https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101398

            Bug ID: 101398
           Summary: Multiple DW_TAG_formal_parameter DIEs for the same
                    parameter
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wcohen at redhat dot com
  Target Milestone: ---

When looking through the debuginfo generated for the Linux kernel code I
noticed some functions had multiple DW_TAG_formal_parameter DIEs for the same
parameter.  Initially I noticed this in
/usr/lib/debug/lib/modules/5.12.7-300.fc34.x86_64/vmlinux on x86_64 Fedora. It
also appeared on locally compiled an upstream kernel compiled with
gcc-11.1.1-3.fc34.x86_64, so it doesn't seem to be caused by debuginfo editing
done when the fedora RPM is produced.

Decoded the debuginfo associated with uv_program_mmr function (one of the
function this issue was observed on):

llvm-dwarfdump  -c --name=uv_program_mmr 
/usr/lib/debug/lib/modules/5.12.7-300.fc34.x86_64/vmlinux >
uv_program_mmr.dwarf

For the uv_program_mmr function see the following where there are two DIE each
for "info" and "cfg".  The multiple copies are referring to the same parameter
as they have the same values for the DW_AT_abstract_origin:

0x00f49737: DW_TAG_subprogram
              DW_AT_abstract_origin     (0x00f493c7 "uv_program_mmr")
              DW_AT_low_pc      (0xffffffff810d0c40)
              DW_AT_high_pc     (0xffffffff810d0cc7)
              DW_AT_frame_base  (DW_OP_call_frame_cfa)
              DW_AT_GNU_all_call_sites  (true)

0x00f4974f:   DW_TAG_variable
                DW_AT_abstract_origin   (0x00f493ec "mmr_value")
                DW_AT_location  (DW_OP_reg2 RCX)

0x00f49757:   DW_TAG_variable
                DW_AT_abstract_origin   (0x00f493f8 "entry")
                DW_AT_location  (0x002ffc4d: 
                   [0xffffffff810d0c4d, 0xffffffff810d0cc7): <decoding error>
f2 4f 97 f4 00 00)
                DW_AT_unknown_2137      (0x002ffc4b)

0x00f49764:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00f493e0 "info")
                DW_AT_location  (0x002ffc77: 
                   [0xffffffff810d0c45, 0xffffffff810d0cc7): <decoding error>
fa 20 d4 00 00 9f)
                DW_AT_unknown_2137      (0x002ffc75)

0x00f49771:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00f493d4 "cfg")
                DW_AT_location  (0x002ffca1: 
                   [0xffffffff810d0c45, 0xffffffff810d0cc7): <decoding error>
fa 14 d4 00 00 9f)
                DW_AT_unknown_2137      (0x002ffc9f)

0x00f4977e:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00f493e0 "info")

0x00f49783:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00f493d4 "cfg")


Also saw the duplicated parameters using a dwgrep
(https://github.com/pmachata/dwgrep), so it doesn't look to be an artifact of
llvm-dwarfdump:

$ dwgrep /usr/lib/debug/lib/modules/5.12.7-300.fc34.x86_64/vmlinux -e '
let A := entry (?TAG_subprogram || ?TAG_inlined_subroutine) !AT_declaration
?AT_abstract_origin;
let ADDR := (A ?DW_AT_low_pc @DW_AT_low_pc || A ?DW_AT_entry_pc @DW_AT_entry_pc
|| 0xffffffff);
let B := [A child ?TAG_formal_parameter @AT_name] ;
let C := [A @AT_abstract_origin child ?TAG_formal_parameter @AT_name];
[A name, ADDR, B, C]'|grep "ffffffff810d0c40"
["uv_program_mmr", 0xffffffff810d0c40, ["info", "cfg", "info", "cfg"], ["cfg",
"info"]]

The associated code appears to be optimized with ISRA as there is an .isra.0
suffix on the disassembled code:


ffffffff810d0c40 <uv_program_mmr.isra.0>:
ffffffff810d0c40:       e8 9b 46 f9 ff          callq  ffffffff810652e0
<__fentry__>
ffffffff810d0c45:       41 89 f0                mov    %esi,%r8d
ffffffff810d0c48:       48 63 f1                movslq %ecx,%rsi
ffffffff810d0c4b:       31 c9                   xor    %ecx,%ecx
ffffffff810d0c4d:       53                      push   %rbx

Reply via email to