public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels
@ 2023-11-03 18:36 gprocida at google dot com
2023-11-03 18:41 ` [Bug debug/112372] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gprocida at google dot com @ 2023-11-03 18:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
Bug ID: 112372
Summary: GCC omits function location in DWARF at higher
optimisation levels
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: gprocida at google dot com
Target Milestone: ---
Source:
void x(signed char c) { (void) c; }
void y(char c) { (void) c; }
void z(unsigned char c) { (void) c; } // not needed
GCC versions tested: 11.4.0, 12.3.0, 13.2.0
DWARF versions tested: 3, 4, 5
Optimisation levels tests: 0, 1, g (all good); 2, 3, fast, s (all bad)
At lower levels of optimisation, the 3 functions are described with
straightforward DIEs.
At higher levels of optimisation, they are... a mess.
x has abstract origin
y is missing location (PC)
z looks normal
The missing location means that binary analysis tools, like libabigail, cannot
associated the symbol y with its type.
FWIW, Clang does not have this issue.
Remove x: issue disappears.
Remove y: issue disappears.
Remove z: issue persists.
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 13.2.0-4'
--with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-13
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-13-oyarai/gcc-13-13.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-oyarai/gcc-13-13.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=28
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Debian 13.2.0-4)
gcc -Wall -Wextra -o x.o -O2 -c -g x.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug debug/112372] GCC omits function location in DWARF at higher optimisation levels
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
@ 2023-11-03 18:41 ` pinskia at gcc dot gnu.org
2023-11-03 18:48 ` gprocida at google dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-03 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=65797,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=63572
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely a dup of bug 65797.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug debug/112372] GCC omits function location in DWARF at higher optimisation levels
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
2023-11-03 18:41 ` [Bug debug/112372] " pinskia at gcc dot gnu.org
@ 2023-11-03 18:48 ` gprocida at google dot com
2023-11-03 18:52 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: gprocida at google dot com @ 2023-11-03 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
--- Comment #2 from Giuliano Procida <gprocida at google dot com> ---
The symbols are not aliased (which is what I thought might have happened with
very aggressive optimisations). If they had been aliased, it would be much
harder to give the symbols types.
0000000000000000 T x
0000000000000010 T y
0000000000000020 T z
Also:
Disassembly of section .text:
0000000000000000 <x>:
0: c3 ret
1: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
8: 00 00 00 00
c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000000010 <y>:
10: c3 ret
11: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
18: 00 00 00 00
1c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000000020 <z>:
20: c3 ret
So it should have been entirely possible to assign the correct byte ranges
(low/high PC) to the 3 functions.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug debug/112372] GCC omits function location in DWARF at higher optimisation levels
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
2023-11-03 18:41 ` [Bug debug/112372] " pinskia at gcc dot gnu.org
2023-11-03 18:48 ` gprocida at google dot com
@ 2023-11-03 18:52 ` pinskia at gcc dot gnu.org
2023-11-03 19:19 ` gprocida at google dot com
2023-11-06 8:06 ` [Bug ipa/112372] " rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-03 18:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Giuliano Procida from comment #2)
> The symbols are not aliased (which is what I thought might have happened
> with very aggressive optimisations). If they had been aliased, it would be
> much harder to give the symbols types.
They can't alias for language reasons that is `&y != &x` (and `&x != &z`) has
to be true. Anyways as mentioned in PR 65797, a thunk is being created and
going wrong.
Yes maybe ICF should not touch empty functions ... But I doubt that was your
original testcase.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug debug/112372] GCC omits function location in DWARF at higher optimisation levels
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
` (2 preceding siblings ...)
2023-11-03 18:52 ` pinskia at gcc dot gnu.org
@ 2023-11-03 19:19 ` gprocida at google dot com
2023-11-06 8:06 ` [Bug ipa/112372] " rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: gprocida at google dot com @ 2023-11-03 19:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
--- Comment #4 from Giuliano Procida <gprocida at google dot com> ---
The provided example was exactly my original test case.
It's part of our test suite for
https://android.googlesource.com/platform/external/stg/.
I'm currently running multiple versions of GCC and Clang over 100s of tests,
looking for discrepancies. There will probably be more bug reports.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/112372] GCC omits function location in DWARF at higher optimisation levels
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
` (3 preceding siblings ...)
2023-11-03 19:19 ` gprocida at google dot com
@ 2023-11-06 8:06 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-06 8:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112372
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|debug |ipa
CC| |hubicka at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Probably a duplicate of a recent similar bug also because of ICF.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-06 8:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-03 18:36 [Bug debug/112372] New: GCC omits function location in DWARF at higher optimisation levels gprocida at google dot com
2023-11-03 18:41 ` [Bug debug/112372] " pinskia at gcc dot gnu.org
2023-11-03 18:48 ` gprocida at google dot com
2023-11-03 18:52 ` pinskia at gcc dot gnu.org
2023-11-03 19:19 ` gprocida at google dot com
2023-11-06 8:06 ` [Bug ipa/112372] " rguenth 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).