This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR 23355 Fix poor Thumb code prologues when generating PIC
- From: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 16 Aug 2005 10:38:37 +0100
- Subject: [PATCH] PR 23355 Fix poor Thumb code prologues when generating PIC
The prologue/epilogue code for Thumb was unconditionally saving and
restoring the PIC register even when the function in question referenced
no static data. This patch uses similar logic to that used for ARM
state so that we now only save the PIC register when it is really
needed. This is especially important on Thumb because the PIC register
is a high register and thus we have to jump through hoops to put it onto
the stack.
Tested on arm-elf with no regressions and by inspection for generating
PIC prologues.
R.
2005-08-15 Richard Earnshaw <richard.earnshaw@arm.com>
PR target/23355
* arm.c (thumb_compute_save_reg_mask): Use similar logic to
arm_compure_save_reg0_reg12_mask to determine when the PIC register
must be saved.
Index: config/arm/arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.472
diff -p -r1.472 arm.c
*** config/arm/arm.c 11 Aug 2005 14:20:23 -0000 1.472
--- config/arm/arm.c 16 Aug 2005 09:26:07 -0000
*************** thumb_compute_save_reg_mask (void)
*** 8935,8945 ****
if (regs_ever_live[reg] && !call_used_regs[reg])
mask |= 1 << reg;
! if (flag_pic && !TARGET_SINGLE_PIC_BASE)
! mask |= (1 << PIC_OFFSET_TABLE_REGNUM);
!
! if (TARGET_SINGLE_PIC_BASE)
! mask &= ~(1 << arm_pic_register);
/* See if we might need r11 for calls to _interwork_r11_call_via_rN(). */
if (!frame_pointer_needed && CALLER_INTERWORKING_SLOT_SIZE > 0)
--- 8935,8944 ----
if (regs_ever_live[reg] && !call_used_regs[reg])
mask |= 1 << reg;
! if (flag_pic
! && !TARGET_SINGLE_PIC_BASE
! && current_function_uses_pic_offset_table)
! mask |= 1 << PIC_OFFSET_TABLE_REGNUM;
/* See if we might need r11 for calls to _interwork_r11_call_via_rN(). */
if (!frame_pointer_needed && CALLER_INTERWORKING_SLOT_SIZE > 0)