public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/111080] New: restrict qualifier leaks debug info
@ 2023-08-20 9:19 sagebar at web dot de
2023-08-20 9:24 ` [Bug debug/111080] restrict qualifier causes extra debug info to happen pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sagebar at web dot de @ 2023-08-20 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
Bug ID: 111080
Summary: restrict qualifier leaks debug info
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: sagebar at web dot de
Target Milestone: ---
The the following code example, debug information is retained for `struct foo`
even though that structure doesn't end up used:
Compile as `gcc -g -S -o - in.c | grep field_number`
```
struct foo {
int field_number_1;
int field_number_2;
int field_number_3;
int field_number_4;
int field_number_5;
};
typedef int fun_t(struct foo *restrict);
int main() {
return 0;
}
```
Output:
gcc -g -S -o - test.c | grep field_number
.ascii "field_number_1\0"
.ascii "field_number_2\0"
.ascii "field_number_3\0"
.ascii "field_number_4\0"
.ascii "field_number_5\0"
When removing the `restrict` qualifier in the parameter of `funptr_t`, debug
information is not included in the produced assembly (as one would expect).
Here is a list of different declarations and where `struct foo` is leaked in
gcc 12.1.0:
> typedef int fun_t(struct foo *restrict); // Leak
> typedef int fun_t(struct foo *); // No leak
> typedef int (*fun_t)(struct foo *restrict); // Leak
> typedef int (*fun_t)(struct foo *); // No leak
> extern int fun_t(struct foo *restrict); // No leak
> extern int fun_t(struct foo *); // No leak
> extern int (*fun_t)(struct foo *restrict); // Leak
> extern int (*fun_t)(struct foo *); // No leak
> static int fun_t(struct foo *restrict); // No leak
> static int fun_t(struct foo *); // No leak
> static int (*fun_t)(struct foo *restrict); // Leak
> static int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
> int fun_t(struct foo *restrict); // No leak
> int fun_t(struct foo *); // No leak
> int (*fun_t)(struct foo *restrict); // Leak
> int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
There is no difference when using `__restrict` or `__restrict__` instead.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
@ 2023-08-20 9:24 ` pinskia at gcc dot gnu.org
2023-08-20 9:28 ` [Bug debug/111080] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-20 9:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> static int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
> int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
The above should include the foo debug information as those are variable
definitions of a pointer to a function that has foo as an argument type.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
2023-08-20 9:24 ` [Bug debug/111080] restrict qualifier causes extra debug info to happen pinskia at gcc dot gnu.org
@ 2023-08-20 9:28 ` pinskia at gcc dot gnu.org
2023-08-20 9:34 ` sagebar at web dot de
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-20 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|restrict qualifier causes |[11/12/13/14 Regression]
|extra debug info to happen |restrict qualifier causes
| |extra debug info to happen
Known to work| |4.9.1
Target Milestone|--- |11.5
Known to fail| |5.1.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
2023-08-20 9:24 ` [Bug debug/111080] restrict qualifier causes extra debug info to happen pinskia at gcc dot gnu.org
2023-08-20 9:28 ` [Bug debug/111080] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-08-20 9:34 ` sagebar at web dot de
2023-08-21 8:30 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sagebar at web dot de @ 2023-08-20 9:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
--- Comment #2 from sagebar at web dot de ---
@Andrew Pinski
Of course: yes. I did make a mistake there, but only for this case:
> int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
asm:
...
.globl fun_t
.section .bss
.align 4
.type fun_t, @object
.size fun_t, 4
fun_t:
.zero 4
...
In the other case:
> static int (*fun_t)(struct foo *); // Leak (even w/o restrict!)
asm:
...
# No data-symbol is generated for `fun_t`
...
Gcc actually doesn't generate a .bss-symbol for the static variable (since it's
unused), but it still generates debug inforation for `struct foo`. So I guess
strike `int (*fun_t)(struct foo *);` from the list, but keep `static int
(*fun_t)(struct foo *);` which still leaks
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (2 preceding siblings ...)
2023-08-20 9:34 ` sagebar at web dot de
@ 2023-08-21 8:30 ` rguenth at gcc dot gnu.org
2023-08-22 12:55 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-21 8:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2023-08-21
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. This is because prune_unused_types_walk marks all restrict types as
necessary. There's also DW_TAG_shared_type that's not handled.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (3 preceding siblings ...)
2023-08-21 8:30 ` rguenth at gcc dot gnu.org
@ 2023-08-22 12:55 ` rguenth at gcc dot gnu.org
2023-08-24 6:23 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-22 12:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Priority|P3 |P2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (4 preceding siblings ...)
2023-08-22 12:55 ` rguenth at gcc dot gnu.org
@ 2023-08-24 6:23 ` cvs-commit at gcc dot gnu.org
2023-08-24 7:10 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-24 6:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:bd2c4d6d8fffd5a6dae5217d6076cc4190bab13d
commit r14-3421-gbd2c4d6d8fffd5a6dae5217d6076cc4190bab13d
Author: Richard Biener <rguenther@suse.de>
Date: Mon Aug 21 10:34:30 2023 +0200
debug/111080 - avoid outputting debug info for unused restrict qualified
type
The following applies some maintainance with respect to type qualifiers
and kinds added by later DWARF standards to prune_unused_types_walk.
The particular case in the bug is not handling (thus marking required)
all restrict qualified type DIEs. I've found more DW_TAG_*_type that
are unhandled, looked up the DWARF docs and added them as well based
on common sense.
PR debug/111080
* dwarf2out.cc (prune_unused_types_walk): Handle
DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type,
DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type
and DW_TAG_dynamic_type as to only output them when referenced.
* gcc.dg/debug/dwarf2/pr111080.c: New testcase.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12/13/14 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (5 preceding siblings ...)
2023-08-24 6:23 ` cvs-commit at gcc dot gnu.org
@ 2023-08-24 7:10 ` cvs-commit at gcc dot gnu.org
2023-08-24 7:10 ` [Bug debug/111080] [11/12 " rguenth at gcc dot gnu.org
2023-12-15 13:17 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-24 7:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:fb6d61299159275246052c72c6e3666b36d5b333
commit r13-7750-gfb6d61299159275246052c72c6e3666b36d5b333
Author: Richard Biener <rguenther@suse.de>
Date: Mon Aug 21 10:34:30 2023 +0200
debug/111080 - avoid outputting debug info for unused restrict qualified
type
The following applies some maintainance with respect to type qualifiers
and kinds added by later DWARF standards to prune_unused_types_walk.
The particular case in the bug is not handling (thus marking required)
all restrict qualified type DIEs. I've found more DW_TAG_*_type that
are unhandled, looked up the DWARF docs and added them as well based
on common sense.
PR debug/111080
* dwarf2out.cc (prune_unused_types_walk): Handle
DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type,
DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type
and DW_TAG_dynamic_type as to only output them when referenced.
* gcc.dg/debug/dwarf2/pr111080.c: New testcase.
(cherry picked from commit bd2c4d6d8fffd5a6dae5217d6076cc4190bab13d)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (6 preceding siblings ...)
2023-08-24 7:10 ` cvs-commit at gcc dot gnu.org
@ 2023-08-24 7:10 ` rguenth at gcc dot gnu.org
2023-12-15 13:17 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-08-24 7:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13/14 Regression] |[11/12 Regression] restrict
|restrict qualifier causes |qualifier causes extra
|extra debug info to happen |debug info to happen
Known to fail| |13.2.0
Known to work| |13.2.1, 14.0
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk and for GCC 13.3 sofar.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug debug/111080] [11/12 Regression] restrict qualifier causes extra debug info to happen
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
` (7 preceding siblings ...)
2023-08-24 7:10 ` [Bug debug/111080] [11/12 " rguenth at gcc dot gnu.org
@ 2023-12-15 13:17 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-15 13:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111080
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:5c3ab44771d0524140cf2ce5de594fcf7fefcd6f
commit r12-10044-g5c3ab44771d0524140cf2ce5de594fcf7fefcd6f
Author: Richard Biener <rguenther@suse.de>
Date: Mon Aug 21 10:34:30 2023 +0200
debug/111080 - avoid outputting debug info for unused restrict qualified
type
The following applies some maintainance with respect to type qualifiers
and kinds added by later DWARF standards to prune_unused_types_walk.
The particular case in the bug is not handling (thus marking required)
all restrict qualified type DIEs. I've found more DW_TAG_*_type that
are unhandled, looked up the DWARF docs and added them as well based
on common sense.
PR debug/111080
* dwarf2out.cc (prune_unused_types_walk): Handle
DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type,
DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type
and DW_TAG_dynamic_type as to only output them when referenced.
* gcc.dg/debug/dwarf2/pr111080.c: New testcase.
(cherry picked from commit bd2c4d6d8fffd5a6dae5217d6076cc4190bab13d)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-12-15 13:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-20 9:19 [Bug debug/111080] New: restrict qualifier leaks debug info sagebar at web dot de
2023-08-20 9:24 ` [Bug debug/111080] restrict qualifier causes extra debug info to happen pinskia at gcc dot gnu.org
2023-08-20 9:28 ` [Bug debug/111080] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-08-20 9:34 ` sagebar at web dot de
2023-08-21 8:30 ` rguenth at gcc dot gnu.org
2023-08-22 12:55 ` rguenth at gcc dot gnu.org
2023-08-24 6:23 ` cvs-commit at gcc dot gnu.org
2023-08-24 7:10 ` cvs-commit at gcc dot gnu.org
2023-08-24 7:10 ` [Bug debug/111080] [11/12 " rguenth at gcc dot gnu.org
2023-12-15 13:17 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).