public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions
@ 2012-12-20 1:12 josh.m.conner at gmail dot com
2012-12-20 1:22 ` [Bug rtl-optimization/55747] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: josh.m.conner at gmail dot com @ 2012-12-20 1:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55747
Bug #: 55747
Summary: Extra registers are saved in functions that only call
noreturn functions
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: josh.m.conner@gmail.com
On architectures such as ARM, where a link register is used to save the return
address, this value does not need to be saved in a function that only calls
noreturn functions.
For example, if I build the following source:
__attribute__((noreturn))
extern void bar (void);
int x;
void foo (void)
{
if (x)
bar ();
}
Using the options "-O2", the link register is saved:
stmfd sp!, {r3, lr}
...
ldmeqfd sp!, {r3, pc}
However, this is unnecessary since the only way the link register cannot be
corrupted since any calls to "bar" will not return.
Note that I am not filing this as an ARM target bug since the issue appears to
be a general problem related to dataflow analysis not tracking the difference
between calls to normal functions and calls to noreturn functions. At any
rate, I see a similar problem in our custom target as well.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/55747] Extra registers are saved in functions that only call noreturn functions
2012-12-20 1:12 [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions josh.m.conner at gmail dot com
@ 2012-12-20 1:22 ` pinskia at gcc dot gnu.org
2013-01-06 8:26 ` hp at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-20 1:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55747
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-20 01:22:11 UTC ---
Actually noreturns are handled special in the compiler. I filed this bug over
6 years ago and it was closed as invalid back then.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/55747] Extra registers are saved in functions that only call noreturn functions
2012-12-20 1:12 [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions josh.m.conner at gmail dot com
2012-12-20 1:22 ` [Bug rtl-optimization/55747] " pinskia at gcc dot gnu.org
@ 2013-01-06 8:26 ` hp at gcc dot gnu.org
2013-10-04 18:46 ` olegendo at gcc dot gnu.org
2013-10-04 20:08 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu.org @ 2013-01-06 8:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55747
Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-01-06
CC| |hp at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #2 from Hans-Peter Nilsson <hp at gcc dot gnu.org> 2013-01-06 08:26:11 UTC ---
Similarly observed for cris-elf with -O2, r194929, JFTR.
If this changes, some attribute markup should be added to keep return-addresses
for noreturn functions, for sake of stack-traces. Also return-addresses need
to be generally kept when -fexceptions and similar are in effect, as noreturn
functions can still throw.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/55747] Extra registers are saved in functions that only call noreturn functions
2012-12-20 1:12 [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions josh.m.conner at gmail dot com
2012-12-20 1:22 ` [Bug rtl-optimization/55747] " pinskia at gcc dot gnu.org
2013-01-06 8:26 ` hp at gcc dot gnu.org
@ 2013-10-04 18:46 ` olegendo at gcc dot gnu.org
2013-10-04 20:08 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: olegendo at gcc dot gnu.org @ 2013-10-04 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55747
Oleg Endo <olegendo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |sh*-*-* arm*-*-* cris*-*-*
CC| |olegendo at gcc dot gnu.org
--- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> ---
On SH there's a similar issue. E.g. compiling
void exit (int __status) __attribute__ ((noreturn));
int test (int a, int b, int c)
{
if (a == b)
return 5;
if (a)
exit (0);
return 0;
}
with -O2 -m4 results in:
_test:
cmp/eq r5,r4
bt/s .L3
tst r4,r4
bf/s .L10
mov #0,r0
rts
nop
.L3:
rts
mov #5,r0
.L10:
mov.l .L11,r1
sts.l pr,@-r15 // push return address register
jsr @r1 // jump to subroutine
mov #0,r4
.L12:
.align 2
.L11:
.long _exit
The jsr should be a simple jmp and the pr push is not required (as with leaf
function calls).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/55747] Extra registers are saved in functions that only call noreturn functions
2012-12-20 1:12 [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions josh.m.conner at gmail dot com
` (2 preceding siblings ...)
2013-10-04 18:46 ` olegendo at gcc dot gnu.org
@ 2013-10-04 20:08 ` rearnsha at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2013-10-04 20:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55747
Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
--- Comment #4 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Sorry, we're not going to change this. Removing the saved lr value would break
back-tracing out of functions that called abort().
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-04 20:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-20 1:12 [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions josh.m.conner at gmail dot com
2012-12-20 1:22 ` [Bug rtl-optimization/55747] " pinskia at gcc dot gnu.org
2013-01-06 8:26 ` hp at gcc dot gnu.org
2013-10-04 18:46 ` olegendo at gcc dot gnu.org
2013-10-04 20:08 ` rearnsha 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).