johannes    02/08/14 14:48:28

  Modified:    gcc/config darwin.c
               gcc/config/rs6000 rs6000.c
  Log:
  Recompute current_function_uses_pic_offset_table at prologue. 3017416.
  
  Revision  Changes    Path
  1.75      +2 -8      gcc3/gcc/config/darwin.c
  
  Index: darwin.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/config/darwin.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- darwin.c  2002/08/14 05:33:18     1.74
  +++ darwin.c  2002/08/14 21:48:26     1.75
  @@ -588,8 +588,7 @@
                              gen_rtx (HIGH, Pmode, offset)));
          emit_insn (gen_rtx (SET, VOIDmode, reg,
                              gen_rtx (LO_SUM, Pmode, reg, offset)));
  -       emit_insn (gen_rtx (USE, VOIDmode,
  -                           gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM)));
  +       emit_insn (gen_rtx (USE, VOIDmode, pic_offset_table_rtx));
   
          orig = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, reg);
   #endif
  @@ -808,8 +807,7 @@
              pic_ref = reg;
   
   #else
  -           emit_insn (gen_rtx (USE, VOIDmode,
  -                           gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM)));
  +           emit_insn (gen_rtx (USE, VOIDmode, pic_offset_table_rtx));
   
              emit_insn (gen_rtx (SET, VOIDmode, reg,
                                  gen_rtx (HIGH, Pmode, 
  @@ -830,10 +828,6 @@
                  emit_move_insn (reg, pic);
                  pic = reg;
                }
  -#if 0
  -           emit_insn (gen_rtx (USE, VOIDmode,
  -                               gen_rtx (REG, Pmode, PIC_OFFSET_TABLE_REGNUM)));
  -#endif
   
              pic_ref = gen_rtx (PLUS, Pmode,
                                 pic, 
  
  
  
  1.166     +28 -0     gcc3/gcc/config/rs6000/rs6000.c
  
  Index: rs6000.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/config/rs6000/rs6000.c,v
  retrieving revision 1.165
  retrieving revision 1.166
  diff -u -r1.165 -r1.166
  --- rs6000.c  2002/08/08 03:19:59     1.165
  +++ rs6000.c  2002/08/14 21:48:27     1.166
  @@ -11961,6 +11961,32 @@
          && (piclabel_name[2] == '+' || piclabel_name[2] == '-')));
   }
   
  +/* APPLE LOCAL recompute PIC register use */
  +/* Sometimes a function has references that require the PIC register,
  +   but optimization removes them all.  To catch this case
  +   recompute current_function_uses_pic_offset_table here. 
  +   This may allow us to eliminate the prologue and epilogue. */
  +
  +static int recompute_PIC_register_use ()
  +{
  +  if (DEFAULT_ABI == ABI_DARWIN 
  +       && flag_pic && current_function_uses_pic_offset_table 
  +       && !cfun->machine->ra_needs_full_frame)
  +    {
  +      rtx insn;
  +      current_function_uses_pic_offset_table = 0;
  +      push_topmost_sequence ();
  +      for (insn = get_insns (); insn != NULL; insn = NEXT_INSN (insn))
  +     if ( reg_mentioned_p (pic_offset_table_rtx, insn))
  +       {
  +         current_function_uses_pic_offset_table = 1;
  +         break;
  +       }
  +      pop_topmost_sequence ();
  +    }
  +  return 0;
  +}
  +       
   /* APPLE LOCAL volatile pic base reg in leaves */
   /* If this is a leaf function and we used any pic-based references,
      see if there is an unused volatile reg we can use instead of R31.
  @@ -12092,6 +12118,8 @@
   void
   rs6000_emit_prologue ()
   {
  +  /* APPLE LOCAL recompute PIC register use */
  +  int dummy ATTRIBUTE_UNUSED = recompute_PIC_register_use ();
     /* APPLE LOCAL volatile pic base reg in leaves */
     int ignored ATTRIBUTE_UNUSED = try_leaf_pic_optimization ();
     rs6000_stack_t *info = rs6000_stack_info ();
  
  
  


Reply via email to