This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/38570] 'GCC/THUMB generates sub-optimal prolog/epilog
- From: "daniel dot sherwood at sepura dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Dec 2008 17:22:38 -0000
- Subject: [Bug c/38570] 'GCC/THUMB generates sub-optimal prolog/epilog
- References: <bug-38570-17095@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from daniel dot sherwood at sepura dot com 2008-12-18 17:22 -------
Following comment received from Richard.Earnshaw@arm.com by e-mail.
======
Hmm, yes, I think this is happening because the body of the function contains
branch instructions. The Thumb branch instructions have quite limited range,
and in the worst case the compiler needs to use the BL instruction (which of
course, will destroy the contents of r14).
Unfortunately, it's nearly impossible to say exactly when it will be necessary
to fall back to this method, so all branches are assumed to do so. It's
relatively unusual to find leaf functions that have branches but do not need to
stack any other registers (non-leaf functions have to save r14 anyway), but
you've managed to find a couple.
R.
[I've just had a quick look at the sources. There appears to be code in there
that is supposed to deal with this case, but it clearly contains broken
assumptions (fortunately, the broken assumptions essentially mean that we
always get correct, though at times sub-optimal, code).]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38570