Various fixes for problems discovered stress-testing GC.
authorAlex Samuel <samuel@gcc.gnu.org>
Wed, 22 Sep 1999 05:51:44 +0000 (05:51 +0000)
committerAlex Samuel <samuel@gcc.gnu.org>
Wed, 22 Sep 1999 05:51:44 +0000 (05:51 +0000)
* config/i386/i386.c (pic_label_name): Change to char pointer.
(global_offset_table): New variable.
(load_pic_register): Fill global_offset_table if it hasn't
already been done.  Allocate pic_label_name dynamically.
* ggc.h (empty_string): New variable.
* ggc-simple.c (empty_string): Likewise.
(init_ggc): Allocate empty_string and add as root.
* stmt.c (digit_strings): New variable.
(init_stmt): Add last_block_end_note as root.  Allocate and
initialize digit_strings.
(expand_asm_operands): Use empty_string and digit_string instead
of string constants.
* profile.c (init_arc_profiler): Allocate with ggc_alloc_string
instead of xmalloc.
(output_func_start_profiler): Likewise.
* c-typeck.c (digest_init): Check if init is error_mark_node.

From-SVN: r29575

gcc/c-typeck.c
gcc/config/i386/i386.c
gcc/ggc-simple.c
gcc/ggc.h
gcc/profile.c
gcc/stmt.c

index de982588d133231f77470e126969429119e91689..07836838f41469f7c16eed300ac4cf1470255b09 100644 (file)
@@ -4494,8 +4494,8 @@ digest_init (type, init, require_constant, constructor_constant)
   enum tree_code code = TREE_CODE (type);
   tree inside_init = init;
 
-  if (init == error_mark_node)
-    return init;
+  if (type == error_mark_node || init == error_mark_node)
+    return error_mark_node;
 
   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
   /* Do not use STRIP_NOPS here.  We do not want an enumerator
index 635b53537c11291c4be9944102decce7eed767ac..f654db645d95af7acedb87954f108bb640bc3e30 100644 (file)
@@ -1357,8 +1357,9 @@ ix86_can_use_return_insn_p ()
   return nregs == 0 || ! frame_pointer_needed;
 }
 \f
-static char pic_label_name[32];
+static char *pic_label_name;
 static int pic_label_output;
+static char *global_offset_table_name;
 
 /* This function generates code for -fpic that loads %ebx with
    the return address of the caller and then returns.  */
@@ -1402,12 +1403,22 @@ load_pic_register ()
 {
   rtx gotsym, pclab;
 
-  gotsym = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
+  if (global_offset_table_name == NULL)
+    {
+      global_offset_table_name = 
+       ggc_alloc_string ("_GLOBAL_OFFSET_TABLE_", 21);
+      ggc_add_string_root (&global_offset_table_name, 1);
+    }
+  gotsym = gen_rtx_SYMBOL_REF (Pmode, global_offset_table_name);
 
   if (TARGET_DEEP_BRANCH_PREDICTION)
     {
-      if (pic_label_name[0] == '\0')
-       ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
+      if (pic_label_name == NULL) 
+       {
+         pic_label_name = ggc_alloc_string (NULL, 32);
+         ggc_add_string_root (&pic_label_name, 1);
+         ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
+       }
       pclab = gen_rtx_MEM (QImode, gen_rtx_SYMBOL_REF (Pmode, pic_label_name));
     }
   else
index 3eeb8c38378e01c7200299db1a468daa374d7a13..536a06e251506313f60f9f28bb7f7b5b5b63ead4 100644 (file)
 #define GGC_ANY_MAGIC          ((unsigned int)0xa9bacbdc)
 #define GGC_ANY_MAGIC_MARK     ((unsigned int)0xa9bacbdc | 1)
 
+/* Constants for general use.  */
+
+char *empty_string;
+
 /* Global lists of roots, rtxs, and trees.  */
 
 struct ggc_rtx
@@ -142,6 +146,9 @@ init_ggc PROTO ((void))
   dump = fopen ("zgcdump", "w");
   setlinebuf (dump);
 #endif
+
+  ggc_alloc_string ("", 0);
+  ggc_add_string_root (&empty_string, 1);
 }
 
 /* Start a new GGC context.  Memory allocated in previous contexts
index de43e9e8ab5436bfd12499de0e9ed41a14df1442..49a8df007492984002f504e4907d82311d1f37e2 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -42,6 +42,9 @@ union  tree_node;
 struct varasm_status;
 struct varray_head_tag;
 
+/* Constants for general use.  */
+extern char *empty_string;
+
 /* Manipulate global roots that are needed between calls to gc.  */
 void ggc_add_root PROTO ((void *base, int nelt, int size, void (*)(void *)));
 void ggc_add_rtx_root PROTO ((struct rtx_def **, int nelt));
index 871f55789cd2a9bfd2c6e98f5809b1ea9ed6769d..9e7cece72d0be751781bb17c8f80d3658553e643 100644 (file)
@@ -1540,7 +1540,7 @@ static void
 init_arc_profiler ()
 {
   /* Generate and save a copy of this so it can be shared.  */
-  char *name = xmalloc (20);
+  char *name = ggc_alloc_string (NULL, 20);
   ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
   profiler_label = gen_rtx_SYMBOL_REF (Pmode, name);
   ggc_add_rtx_root (&profiler_label, 1);
@@ -1678,10 +1678,11 @@ output_func_start_profiler ()
   expand_function_start (fndecl, 0);
 
   /* Actually generate the code to call __bb_init_func. */
-  name = xmalloc (20);
+  name = ggc_alloc_string (NULL, 20);
   ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 0);
   table_address = force_reg (Pmode, gen_rtx_SYMBOL_REF (Pmode, name));
-  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__bb_init_func"), 0,
+  emit_library_call (gen_rtx_SYMBOL_REF 
+                    (Pmode, ggc_alloc_string ("__bb_init_func", 14)), 0,
                     mode, 1, table_address, Pmode);
 
   expand_function_end (input_filename, lineno, 0);
index 6483da5bcc5211d1cd0e624e5b8edd554fce438f..f2180bf4944ddd0154f277f59dfeb4f27f6926fc 100644 (file)
@@ -401,6 +401,9 @@ struct stmt_status
 /* Non-zero if we are using EH to handle cleanus.  */
 static int using_eh_for_cleanups_p = 0;
 
+/* Character strings, each containing a single decimal digit.  */
+static char *digit_strings[10];
+
 
 static int n_occurrences               PROTO((int, const char *));
 static void expand_goto_internal       PROTO((tree, rtx, rtx));
@@ -592,7 +595,17 @@ mark_stmt_status (p)
 void
 init_stmt ()
 {
+  int i;
+
   gcc_obstack_init (&stmt_obstack);
+  ggc_add_rtx_root (&last_block_end_note, 1);
+
+  for (i = 0; i < 10; i++)
+    {
+      digit_strings[i] = ggc_alloc_string (NULL, 1);
+      digit_strings[i][0] = '0' + i;
+    }
+  ggc_add_string_root (digit_strings, 10);
 }
 
 void
@@ -1547,9 +1560,9 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   argvec = rtvec_alloc (ninputs);
   constraints = rtvec_alloc (ninputs);
 
-  body = gen_rtx_ASM_OPERANDS (VOIDmode,
-                              TREE_STRING_POINTER (string), "", 0, argvec,
-                              constraints, filename, line);
+  body = gen_rtx_ASM_OPERANDS (VOIDmode, TREE_STRING_POINTER (string), 
+                              empty_string, 0, argvec, constraints, 
+                              filename, line);
 
   MEM_VOLATILE_P (body) = vol;
 
@@ -1717,14 +1730,12 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   /* For in-out operands, copy output rtx to input rtx. */
   for (i = 0; i < ninout; i++)
     {
-      static char match[9+1][2]
-       = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
       int j = inout_opnum[i];
 
       XVECEXP (body, 3, ninputs - ninout + i)      /* argvec */
        = output_rtx[j];
       XVECEXP (body, 4, ninputs - ninout + i)      /* constraints */
-       = gen_rtx_ASM_INPUT (inout_mode[i], match[j]);
+       = gen_rtx_ASM_INPUT (inout_mode[i], digit_strings[j]);
     }
 
   /* Now, for each output, construct an rtx