[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2021-12-09 Thread wcohen at redhat dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

--- Comment #7 from Will Cohen  ---
Created attachment 51963
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51963=edit
Reproducer showing duplicate formal parameters from kernel probe_rom.i

Compiled with following to generate probe_rom.o with duplicate k formal
parameters in the debuginfo:

gcc  -Wp,-MMD,arch/x86/kernel/.probe_roms.o.d -nostdinc -D__KERNEL__
-fmacro-pre
fix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs
-fno-strict-a
liasing -fno-common -fshort-wchar -fno-PIE
-Werror=implicit-function-declaration
 -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89
-mno-s
se -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64
-falign-jump
s=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3
-
mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
-
fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern
-mindirect-branch-
register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address
-Wn
o-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2
-fno-
allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong
"-Wimpl
icit-fallthrough=5" -Wno-main -Wno-unused-but-set-variable
-Wno-unused-const-var
iable -fno-stack-clash-protection -pg -mrecord-mcount -mfentry
-DCC_USING_FENTRY
 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation 
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-
Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow
-fno-st
ack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types 
-Werror=designated-init -Wno-packed-not-aligned -g   
-DKBUILD_MODFILE='"arch/x8
6/kernel/probe_roms"' -DKBUILD_BASENAME='"probe_roms"'
-DKBUILD_MODNAME='"probe_
roms"' -D__KBUILD_MODNAME=kmod_probe_roms -c -o probe_roms.o probe_roms.i

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2021-12-09 Thread wcohen at redhat dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

Will Cohen  changed:

   What|Removed |Added

 CC||wcohen at redhat dot com

--- Comment #6 from Will Cohen  ---
I have similar duplications of formal parameters in some of the code compiled
linux kernel code.  I had a dwgrep (https://pmachata.github.io/dwgrep/) that
would print out each function and location with more formal parameters than
listed in the abstract origin:

 dwgrep vmlinux  -e '
let A := entry (?TAG_subprogram) !AT_declaration;
let FSTART := ((A ?AT_entry_pc @AT_entry_pc) || (A ?AT_ranges @AT_ranges low)
|| ( A low));
let B := [A child ?TAG_formal_parameter name] ;
let ABS_ORIGIN := A @AT_abstract_origin;
let C := [ABS_ORIGIN child ?TAG_formal_parameter name];
(C length != B length) B C A name FSTART'

Looking through the functions flagged I found match_id in
/arch/x86/kernel/probe_roms.c looked small and could be a starting point for a
reproducer (two pdev formal parameters):

0x8102eec0
match_id
["pdev", "vendor", "device"]
["vendor", "device", "pdev", "pdev"]


The  "llvm-dwarfdump -c --name=match_id vmlinux" show the duplicate pdev formal
parameters in its output:

0x005741ea: DW_TAG_subprogram
  DW_AT_abstract_origin (0x00574134 "match_id")
  DW_AT_low_pc  (0x8102eec0)
  DW_AT_high_pc (0x8102ef1a)
  DW_AT_frame_base  (DW_OP_call_frame_cfa)
  DW_AT_call_all_calls  (true)
  DW_AT_sibling (0x00574291)

0x00574206:   DW_TAG_formal_parameter
DW_AT_abstract_origin   (0x00574151 "vendor")
DW_AT_location  (0x0006ebe0: 
   [0x8102eec0, 0x8102eee0): DW_OP_reg2 RCX
   [0x8102eee0, 0x8102ef1a): DW_OP_reg4 RSI)
DW_AT_GNU_entry_view(0x0006ebdc)

0x00574213:   DW_TAG_formal_parameter
DW_AT_abstract_origin   (0x0057415d "device")
DW_AT_location  (DW_OP_reg8 R8)

0x0057421b:   DW_TAG_variable
DW_AT_abstract_origin   (0x00574169 "drv")
DW_AT_location  (0x0006ebf6: 
   [0x8102eeeb, 0x8102eeff): DW_OP_reg2 RCX)
DW_AT_GNU_entry_view(0x0006ebf4)

0x00574228:   DW_TAG_variable
DW_AT_abstract_origin   (0x00574174 "id")
DW_AT_location  (0x0006ec09: 
   [0x8102eef8, 0x8102eeff): DW_OP_reg1 RDX
   [0x8102eeff, 0x8102ef03): DW_OP_breg1
RDX+40, DW_OP_stack_value
   [0x8102ef03, 0x8102ef19): DW_OP_reg1 RDX)
DW_AT_GNU_entry_view(0x0006ec03)

0x00574235:   DW_TAG_formal_parameter
DW_AT_abstract_origin   (0x00574145 "pdev")
DW_AT_location  (0x0006ec26: 
   [0x8102eec0, 0x8102ef1a): 
fa c7 cc 00 00 9f)
DW_AT_GNU_entry_view(0x0006ec24)

0x00574242:   DW_TAG_formal_parameter
DW_AT_abstract_origin   (0x00574145 "pdev")

The probe_rom.i file was used a a starting point to create a smaller reproducer
with creduce which can be compiled with:

gcc  -Wp,-MMD,arch/x86/kernel/.probe_roms.o.d -nostdinc -D__KERNEL__
-fmacro-pre
fix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs
-fno-strict-a
liasing -fno-common -fshort-wchar -fno-PIE
-Werror=implicit-function-declaration
 -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89
-mno-s
se -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64
-falign-jump
s=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3
-
mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
-
fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern
-mindirect-branch-
register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address
-Wn
o-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2
-fno-
allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong
"-Wimpl
icit-fallthrough=5" -Wno-main -Wno-unused-but-set-variable
-Wno-unused-const-var
iable -fno-stack-clash-protection -pg -mrecord-mcount -mfentry
-DCC_USING_FENTRY
 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation 
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-
Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow
-fno-st
ack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types 
-Werror=designated-init -Wno-packed-not-aligned -g   
-DKBUILD_MODFILE='"arch/x8
6/kernel/probe_roms"' -DKBUILD_BASENAME='"probe_roms"'
-DKBUILD_MODNAME='"probe_
roms"' -D__KBUILD_MODNAME=kmod_probe_roms -c -o probe_roms.o probe_roms.i

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2020-09-08 Thread simon.marchi at polymtl dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

--- Comment #5 from Simon Marchi  ---
(In reply to Richard Biener from comment #3)
> Hmm, can you point out the issue in the reduced testcase?  I can't see it. 
> The only cloning done I see is partial inlining so does
> -fno-partial-inlining fix the issue for you?

Doh, I indeed uploaded the wrong thing.  My creduce test was trying to
reproduce the "wrong parameter order" problem, which I later found was probably
not considered a bug, instead of the "duplicate parameter problem".  I re-ran
it with the right test, I attached the result.

The relevant portion of the DWARF is:

0x03bb:   DW_TAG_subprogram
DW_AT_abstract_origin   (0x0383 "do_examine")
DW_AT_low_pc(0x)
DW_AT_high_pc   (0x0039)
DW_AT_frame_base(DW_OP_call_frame_cfa)
DW_AT_GNU_all_call_sites(true)
DW_AT_sibling   (0x0464)

0x03d6: DW_TAG_variable
  DW_AT_abstract_origin (0x03a4 "ai")

0x03db: DW_TAG_variable
  DW_AT_abstract_origin (0x03af "aq")
  DW_AT_location(DW_OP_fbreg -17)

0x03e3: DW_TAG_formal_parameter
  DW_AT_abstract_origin (0x039f)
  DW_AT_location( 9f 03 00 00 9f)

0x03ef: DW_TAG_formal_parameter
  DW_AT_abstract_origin (0x039a)
  DW_AT_location( 9a 03 00 00 9f)

0x03fb: DW_TAG_formal_parameter
  DW_AT_abstract_origin (0x0390 "y")

0x0400: DW_TAG_formal_parameter
  DW_AT_abstract_origin (0x0390 "y")

The last two DW_TAG_formal_parameter refer to the same parameter.

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2020-09-08 Thread simon.marchi at polymtl dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

--- Comment #4 from Simon Marchi  ---
Created attachment 49198
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49198=edit
Output from creduce

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2020-09-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

Richard Biener  changed:

   What|Removed |Added

 CC||rguenth at gcc dot gnu.org
   Last reconfirmed||2020-09-07
 Status|UNCONFIRMED |WAITING
 Ever confirmed|0   |1

--- Comment #3 from Richard Biener  ---
Hmm, can you point out the issue in the reduced testcase?  I can't see it.  The
only cloning done I see is partial inlining so does -fno-partial-inlining fix
the issue for you?

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2020-09-04 Thread simon.marchi at polymtl dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

--- Comment #2 from Simon Marchi  ---
Created attachment 49181
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49181=edit
Output from creduce

I compile the reproducer program with:

/opt/gcc/git/bin/g++ -x c++ -g3 -O2 -c bug.c

[Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance

2020-09-04 Thread simon.marchi at polymtl dot ca
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

--- Comment #1 from Simon Marchi  ---
I passed the program in creduce, the result is not pretty but it's not too big
and still reproduces the problem, so I'll attach it anyway.