This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions
- From: "josh.m.conner at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 20 Dec 2012 01:12:40 +0000
- Subject: [Bug rtl-optimization/55747] New: Extra registers are saved in functions that only call noreturn functions
- Auto-submitted: auto-generated
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.