This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[arm] Redundant return instructions
- From: Paul Brook <paul at codesourcery dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Earnshaw <rearnsha at arm dot com>
- Date: Thu, 24 Jun 2004 01:13:35 +0100
- Subject: [arm] Redundant return instructions
- Organization: CodeSourcery
We currently emit a redundant return instruction when a function has pertend
args and a frame pointer.
For example, when the following code compiled with -O2 -fno-omit-frame-pointer
int
foo (int num, ...)
{
return num;
}
The last two instructions are
ldmfd sp, {fp, sp, pc}
mov pc, lr
This is a regression caused by my earlier cleanup in this area. Patch below
fixes it.
The conditions removed do not apply when a frame pointer is used.
When a frame pointer is used the check is redundant as the same condition is
used to set saved_regs_mask|(1<<PC_REGNUM) earlier in the function.
Tested with cross to arm-none-elf.
Ok?
2004-06-24 Paul Brook <paul@codesourcery.com>
* config/arm/arm.c (arm_output_epilogue): Remove excess checks.
Index: config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.365
diff -u -p -r1.365 arm.c
--- config/arm/arm.c 28 May 2004 16:00:00 -0000 1.365
+++ config/arm/arm.c 24 Jun 2004 00:03:36 -0000
@@ -9705,10 +9705,7 @@ arm_output_epilogue (rtx sibling)
}
/* We may have already restored PC directly from the stack. */
- if (! really_return
- || (ARM_FUNC_TYPE (func_type) == ARM_FT_NORMAL
- && current_function_pretend_args_size == 0
- && saved_regs_mask & (1 << PC_REGNUM)))
+ if (!really_return || saved_regs_mask & (1 << PC_REGNUM))
return "";
/* Generate the return instruction. */