public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59394] New: Unused code generated
@ 2013-12-05 11:06 smal.root at gmail dot com
2013-12-05 11:07 ` [Bug c++/59394] " smal.root at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: smal.root at gmail dot com @ 2013-12-05 11:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
Bug ID: 59394
Summary: Unused code generated
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: smal.root at gmail dot com
Target: AVR
Created attachment 31385
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31385&action=edit
source code
GCC:
avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.8.2/lto-wrapper
Target: avr
Configured with: /build/avr-gcc/src/gcc-4.8.2/configure
--disable-cloog-version-check --disable-install-libiberty --disable-libssp
--disable-libstdcxx-pch --disable-libunwind-exceptions
--disable-linker-build-id --disable-nls --disable-werror --enable-__cxa_atexit
--enable-checking=release --enable-clocale=gnu --enable-cloog-backend=isl
--enable-gnu-unique-object --enable-gold --enable-languages=c,c++
--enable-ld=default --enable-lto --enable-plugin --enable-shared
--infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --prefix=/usr --target=avr --with-as=/usr/bin/avr-as
--with-gnu-as --with-gnu-ld --with-ld=/usr/bin/avr-ld --with-plugin-ld=ld.gold
--with-system-zlib
Thread model: single
gcc version 4.8.2 (GCC)
OS:
Arch Linux
Linux 3.12.0-1-ARCH #1 SMP PREEMPT Wed Nov 6 09:06:27 CET 2013 x86_64 GNU/Linux
Command line:
avr-gcc -Wall -mmcu=atxmega64a3 -DF_CPU=16000000UL -mno-interrupts -Os
-pedantic-errors -pedantic -std=c++11 -Wfatal-errors -Wall
-I/usr/avr/include -c main.cpp -o obj/Release/main.o
main.cpp: In function 'int main()':
main.cpp:55:21: warning: variable 'tval32' set but not used
[-Wunused-but-set-variable]
volatile uint32_t tval32;
^
avr-g++ -o bin/Release/lambda_test.elf obj/Release/main.o -mmcu=atxmega64a3
-Wl,-Map=bin/Release/lambda_test.map,--cref
Output size is 7,92 KB
Running project post-build steps
avr-size bin/Release/lambda_test.elf
text data bss dec hex filename
850 0 2400 3250 cb2
bin/Release/lambda_test.elf
avr-objdump -h -S bin/Release/lambda_test.elf > bin/Release/lambda_test.lss
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings (0 minutes, 0 seconds)
Source file: attached main.cpp
Generated assembly: attached lambda_test.lss
Problem.
A. As you can see in generated assembly:
1. function Sort_OldStyle(_Z13Sort_OldStylev) contain(as inline) functions Sort
and Sort_OldStyle_Internal
2. function Sort_NewStyle(_Z13Sort_NewStylev) contain(as inline) functions Sort
and lambda-expression
B. But also generated code contain unneded:
1. function Sort(_Z4SortPV5SPairS1_PFvRS0_E)
2. function Sort_OldStyle_Internal(_Z22Sort_OldStyle_InternalRV5SPair)
3. lambda-expression(_ZZ13Sort_NewStylevENUlRV5SPairE_4_FUNES1_)
Why gcc include functions from B-list if they already exist in functions of
list A? Also why gcc use inline for function Sort and don't use call with -Os
used?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
@ 2013-12-05 11:07 ` smal.root at gmail dot com
2013-12-22 15:11 ` gjl at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: smal.root at gmail dot com @ 2013-12-05 11:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
--- Comment #1 from smalcom <smal.root at gmail dot com> ---
Created attachment 31386
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31386&action=edit
generated assembly
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
2013-12-05 11:07 ` [Bug c++/59394] " smal.root at gmail dot com
@ 2013-12-22 15:11 ` gjl at gcc dot gnu.org
2013-12-22 15:12 ` gjl at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-12-22 15:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31385|0 |1
is obsolete| |
--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Created attachment 31500
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31500&action=edit
C++ source.
Please follow the bug reporting instructions and don't include headers,
especcialy ones that the common GCC developer does not have.
Attached a source file that compiles fine without headers.
And there is nothing avr specific here.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
2013-12-05 11:07 ` [Bug c++/59394] " smal.root at gmail dot com
2013-12-22 15:11 ` gjl at gcc dot gnu.org
@ 2013-12-22 15:12 ` gjl at gcc dot gnu.org
2013-12-22 16:43 ` gjl at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-12-22 15:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|AVR |
Severity|major |normal
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
` (2 preceding siblings ...)
2013-12-22 15:12 ` gjl at gcc dot gnu.org
@ 2013-12-22 16:43 ` gjl at gcc dot gnu.org
2021-12-23 7:00 ` [Bug middle-end/59394] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: gjl at gcc dot gnu.org @ 2013-12-22 16:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Some more notes:
If you don't want that small functions are being inlined, consider
-fno-inline-small-functions.
If a function is being inlined then it's body is still implemented except in
the case where GCC can prove the body is never needed, for example if the
function is static.
If you implement two functions that result in the same code, GCC won't reuse
the code for you. If you have redundant code, it is up to you to reuse it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
` (3 preceding siblings ...)
2013-12-22 16:43 ` gjl at gcc dot gnu.org
@ 2021-12-23 7:00 ` pinskia at gcc dot gnu.org
2021-12-23 8:02 ` smal.root at gmail dot com
2021-12-23 8:04 ` smal.root at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-23 7:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
If I use -Wl,--gc-sections -ffunction-sections, then all of the unused
(non-static) functions are removed.
Also -flto is able to optimize it too.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
` (4 preceding siblings ...)
2021-12-23 7:00 ` [Bug middle-end/59394] " pinskia at gcc dot gnu.org
@ 2021-12-23 8:02 ` smal.root at gmail dot com
2021-12-23 8:04 ` smal.root at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: smal.root at gmail dot com @ 2021-12-23 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
--- Comment #5 from smalcom <smal.root at gmail dot com> ---
Created attachment 52049
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52049&action=edit
Generated assembly when using "gc-section". avr-gcc-10.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/59394] Unused code generated
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
` (5 preceding siblings ...)
2021-12-23 8:02 ` smal.root at gmail dot com
@ 2021-12-23 8:04 ` smal.root at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: smal.root at gmail dot com @ 2021-12-23 8:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59394
--- Comment #6 from smalcom <smal.root at gmail dot com> ---
Created attachment 52050
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52050&action=edit
Generated assembly when using "LTO". avr-gcc-10.2
(In reply to Andrew Pinski from comment #4)
> If I use -Wl,--gc-sections -ffunction-sections, then all of the unused
> (non-static) functions are removed.
>
> Also -flto is able to optimize it too.
I confirm that:
1. With set "-Wl,--gc-sections -ffunction-sections" output file do not contain
unused functions (attached gcsec.lss).
2. With "-flto" all functions are inlined and present only used code (attached
lto.lss).
Tested using gcc-10:
avr-gcc -v
Using built-in specs.
Reading specs from
/mnt/stor5/opt/сборка/avr-10.2.0/bin/../lib/gcc/avr/10.2.0/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/mnt/stor5/opt/сборка/avr-10.2.0/bin/../libexec/gcc/avr/10.2.0/lto-wrapper
Target: avr
Configured with: ../configure --prefix=/opt/toolchain/avr-10.2.0 --target=avr
--enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
Great. Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-23 8:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-05 11:06 [Bug c++/59394] New: Unused code generated smal.root at gmail dot com
2013-12-05 11:07 ` [Bug c++/59394] " smal.root at gmail dot com
2013-12-22 15:11 ` gjl at gcc dot gnu.org
2013-12-22 15:12 ` gjl at gcc dot gnu.org
2013-12-22 16:43 ` gjl at gcc dot gnu.org
2021-12-23 7:00 ` [Bug middle-end/59394] " pinskia at gcc dot gnu.org
2021-12-23 8:02 ` smal.root at gmail dot com
2021-12-23 8:04 ` smal.root at gmail dot com
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).