rs6000.c (rs6000_emit_prologue): Don't clone the result of machopic_function_base_name.
authorGeoffrey Keating <geoffk@apple.com>
Wed, 19 Mar 2003 03:23:44 +0000 (03:23 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Wed, 19 Mar 2003 03:23:44 +0000 (03:23 +0000)
* config/rs6000/rs6000.c (rs6000_emit_prologue): Don't clone
the result of machopic_function_base_name.
* config/darwin.c (machopic_function_base_name): Use a gc-allocated
string rather than a static array.

From-SVN: r64569

gcc/ChangeLog
gcc/config/darwin.c
gcc/config/rs6000/rs6000.c

index 656425460f1b06a5887503fa1049606f8968d957..4c8d0b41d5d010b886c112f90b7470a01c066b1c 100644 (file)
 
 2003-03-18  Geoffrey Keating  <geoffk@apple.com>
 
+       * config/rs6000/rs6000.c (rs6000_emit_prologue): Don't clone
+       the result of machopic_function_base_name.
+       * config/darwin.c (machopic_function_base_name): Use a gc-allocated
+       string rather than a static array.
+
        * Makefile.in (emit-rtl.o): Add gt-emit-rtl.h to dependencies.
 
        * gengtype.c: Include rtl.h.
index 86b3425545a0cdc1fab215e6ef817791b57580a5..934d99725bfd675fe2088989192a95f499f08b86 100644 (file)
@@ -219,24 +219,26 @@ machopic_define_name (name)
 }
 
 /* This is a static to make inline functions work.  The rtx
-   representing the PIC base symbol always points to here.  */
+   representing the PIC base symbol always points to here.  
 
-static char function_base[32];
+   FIXME: The rest of the compiler doesn't expect strings to change.  */
 
+static GTY(()) char * function_base;
+static GTY(()) const char * function_base_func_name;
 static GTY(()) int current_pic_label_num;
 
 const char *
 machopic_function_base_name ()
 {
-  static const char *name = NULL;
-  static const char *current_name;
+  const char *current_name;
 
   /* if dynamic-no-pic is on, we should not get here */
   if (MACHO_DYNAMIC_NO_PIC_P)
     abort ();
-  current_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
+  current_name = 
+    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
 
-  if (name != current_name)
+  if (function_base_func_name != current_name)
     {
       current_function_uses_pic_offset_table = 1;
 
@@ -246,13 +248,21 @@ machopic_function_base_name ()
         by the incredibly scientific test below.  This is because code in
         rs6000.c makes the same ugly test when loading the PIC reg.  */
  
+      /* It's hard to describe just how ugly this is.  The reason for
+         the '%011d' is that after a PCH load, we can't change the
+         size of the string, because PCH will have uniqued it and
+         allocated it in the string pool.  */
+      if (function_base == NULL)
+       function_base = 
+         (char *) ggc_alloc_string ("", sizeof ("*\"L12345678901$pb\""));
+
       ++current_pic_label_num;
       if (*current_name == '+' || *current_name == '-')
-       sprintf (function_base, "*\"L-%d$pb\"", current_pic_label_num);
+       sprintf (function_base, "*\"L-%010d$pb\"", current_pic_label_num);
       else
-       sprintf (function_base, "*L%d$pb", current_pic_label_num);
+       sprintf (function_base, "*\"L%011d$pb\"", current_pic_label_num);
 
-      name = current_name;
+      function_base_func_name = current_name;
     }
 
   return function_base;
index b78e837b2c1d7572ed682d81627e8e1e1a1952bf..ff3f940fca9ac3f0d1e7848456efcd31ab1b7526 100644 (file)
@@ -10799,7 +10799,7 @@ rs6000_emit_prologue ()
     {
       rtx dest = gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM);
       const char *picbase = machopic_function_base_name ();
-      rtx src = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
+      rtx src = gen_rtx_SYMBOL_REF (Pmode, picbase);
 
       rs6000_maybe_dead (emit_insn (gen_load_macho_picbase (dest, src)));