This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[arm] Fix -fpic


The Arm function prologue code only saves/restores the PIC base register when 
regs_ever_live[PIC_OFFSET_TABLE_REGNUM]. However reloading the pic register 
is conditional on current_function_uses_pic_offset_table. These can have 
different values if all PIC references in a function are eliminated.

The patch below saves uses current_function_uses_pic_offset_table in both 
cases. It may be possible to eliminate this variable altogether, and just use 
live register information. However I don't feel confident enough to make that 
change in stage3.

Tested with cross to arm-none-elf.
Applied to mainline and csl-arm-branch.

Paul

2004-11-03  Paul Brook  <paul@codesourcery.com>

 * config/arm/arm.c (arm_compute_save_reg0_reg12_mask): Save PIC
 register if current_function_uses_pic_offset_table is set.

Index: config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.303.2.60
diff -u -p -r1.303.2.60 arm.c
--- config/arm/arm.c 13 Oct 2004 12:49:28 -0000 1.303.2.60
+++ config/arm/arm.c 3 Nov 2004 16:41:19 -0000
@@ -9040,6 +9040,12 @@ arm_compute_save_reg0_reg12_mask (void)
  if (regs_ever_live[reg]
      || (! current_function_is_leaf && call_used_regs [reg]))
    save_reg_mask |= (1 << reg);
+
+      /* Also save the pic base register if neccessary.  */
+      if (flag_pic
+   && !TARGET_SINGLE_PIC_BASE
+   && current_function_uses_pic_offset_table)
+ save_reg_mask |= 1 << PIC_OFFSET_TABLE_REGNUM;
     }
   else
     {
@@ -9059,8 +9065,9 @@ arm_compute_save_reg0_reg12_mask (void)
       /* If we aren't loading the PIC register,
   don't stack it even though it may be live.  */
       if (flag_pic
-   && ! TARGET_SINGLE_PIC_BASE 
-   && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
+   && !TARGET_SINGLE_PIC_BASE 
+   && (regs_ever_live[PIC_OFFSET_TABLE_REGNUM]
+       || current_function_uses_pic_offset_table))
  save_reg_mask |= 1 << PIC_OFFSET_TABLE_REGNUM;
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]