]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport of GC branch patches part 2: kill stmt status saving.
authorBernd Schmidt <bernds@cygnus.co.uk>
Sun, 1 Aug 1999 12:07:41 +0000 (12:07 +0000)
committerBernd Schmidt <crux@gcc.gnu.org>
Sun, 1 Aug 1999 12:07:41 +0000 (12:07 +0000)
From-SVN: r28374

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/typeck.c
gcc/emit-rtl.c
gcc/function.c
gcc/function.h
gcc/rtl.h
gcc/stmt.c
gcc/tree.h

index a4d4349336cdbfdf54bdff84e04459ae23d8c5d3..66da0db726fa742b5a64a85b2e144298fd1aa3ed 100644 (file)
@@ -1,3 +1,48 @@
+Sun Aug  1 12:55:31 1999  Bernd Schmidt  <bernds@cygnus.co.uk>
+
+       * stmt.c (emit_filename, emit_lineno, expr_stmts_for_value,
+       last_expr_type, last_expr_value, block_start_count, block_stack,
+       stack_block_stack, cond_stack, loop_stack, case_stack, nesting_stack,
+       nesting_depth, goto_fixup_chain): Delete global vars; now allocated
+       dynamically in stmt elt of struct function for each function.
+       (struct nesting): Rename function_call_count elt to n_function_calls,
+       target_temp_slot_level to block_target_temp_slot_level.  All users
+       changed.
+       (struct stmt_status): New structure definition.
+       Add many accessor macros for stmt_status elements which previously
+       were global variables.
+       (init_stmt_for_function): Allocate stmt elt for current_function.
+       Reflect that block_start_count was renamed to
+       current_block_start_count.
+       (save_stmt_status, restore_stmt_status): Delete functions.
+       (preserve_subexpressions_p): Don't access loop_stack when outside
+       a function.
+       (expand_start_bindings): Reflect that block_start_count was renamed to
+       current_block_start_count.
+       (expand_fixup): Likewise.
+       (expand_decl): Don't access block_stack when outside a function.
+       (expand_decl_cleanup): Likewise.
+       (expand_dcc_cleanup): Likewise.
+       (expand_dhc_cleanup): Likewise.
+       (expand_anon_union_decl): Likewise.
+       (set_file_and_line_for_stmt): New function.
+       (in_control_zone_p): New function.
+
+       * function.h (struct function): Add new elt stmt.
+       Delete elts block_stack, stack_block_stack, cond_stack, loop_stack,
+       case_stack, nesting_stack, nesting_depth, block_start_count,
+       last_expr_type, last_expr_value, expr_stmts_for_value, emit_filename,
+       emit_lineno, goto_fixup_chain.
+       (save_eh_status, restore_eh_status, save_stmt_status,
+       restore_stmt_status): Delete declarations.
+       * function.c (push_function_context_to): Don't call save_stmt_status.
+       (pop_function_context_to): Don't call restore_stmt_status.
+       * tree.h (in_control_zone_p): Declare.
+       * rtl.h (set_file_and_line_for_stmt): Declare.
+
+       * emit-rtl.c (emit_line_note): Don't set emit_filename/emit_lineno;
+       call set_file_and_line_for_stmt.
+
 Thu Jul 31 12:34:45 1999  Joe Buck  <jbuck@synopsys.com>
 
        * gcc.texi: Use terms "GNU Compiler Collection" and "GCC".
index a6f75c53f3d373992f12dd49242d90e874dd5087..b70b803e9f5e0cff52873a3807ff886a6da39519 100644 (file)
@@ -1,3 +1,9 @@
+1999-08-01  Bernd Schmidt  <bernds@cygnus.co.uk>
+
+       * decl.c (finish_stmt): Don't declare and test cond_stack, loop_stack,
+       case_stack; use in_control_zone_p.
+       * typeck.c (c_expand_return): Likewise.
+
 1999-07-31  Bernd Schmidt  <bernds@cygnus.co.uk>
 
        * except.c (catch_clauses): Delete declaration.
index 1dc070b108dfac5477e9d6ef67b5a2771772bcc0..bbbf7be89e181e67e2c97a618c00242ca7419ecf 100644 (file)
@@ -14509,9 +14509,6 @@ cplus_expand_expr_stmt (exp)
 void
 finish_stmt ()
 {
-  extern struct nesting *cond_stack, *loop_stack, *case_stack;
-
-  
   if (current_function_assigns_this
       || ! current_function_just_assigned_this)
     return;
@@ -14519,7 +14516,7 @@ finish_stmt ()
     {
       /* Constructors must wait until we are out of control
         zones before calling base constructors.  */
-      if (cond_stack || loop_stack || case_stack)
+      if (in_control_zone_p ())
        return;
       expand_expr_stmt (base_init_expr);
       check_base_init (current_class_type);
index e62f7e34e3f67c7cd9cde09ae26f3fc1dd44dd89..cd0652f7529aebe12cb916f71f9a1d04e8ede457 100644 (file)
@@ -6735,7 +6735,6 @@ void
 c_expand_return (retval)
      tree retval;
 {
-  extern struct nesting *cond_stack, *loop_stack, *case_stack;
   extern tree dtor_label, ctor_label;
   tree result = DECL_RESULT (current_function_decl);
   tree valtype = TREE_TYPE (result);
@@ -6925,7 +6924,7 @@ c_expand_return (retval)
 
   if (retval != NULL_TREE
       && TREE_CODE_CLASS (TREE_CODE (retval)) == 'd'
-      && cond_stack == 0 && loop_stack == 0 && case_stack == 0)
+      && ! in_control_zone_p ())
     current_function_return_value = retval;
 
   if (ctor_label && TREE_CODE (ctor_label) != ERROR_MARK)
index 43fa8d9ba50aff2db48d7c5c01c9a338c2cf28a1..3c0e08c5e838287756459727a17483614131bffd 100644 (file)
@@ -3167,8 +3167,7 @@ emit_line_note (file, line)
      char *file;
      int line;
 {
-  emit_filename = file;
-  emit_lineno = line;
+  set_file_and_line_for_stmt (file, line);
 
 #if 0
   if (no_line_numbers)
index cf4ed867a985e5651957466b9bd71b9862b9e058..3467de0c708bad406d8c1c9070c5f34e55820c36 100644 (file)
@@ -626,7 +626,6 @@ push_function_context_to (context)
   save_storage_status (p);
   save_emit_status (p);
   save_expr_status (p);
-  save_stmt_status (p);
   save_varasm_status (p, context);
   if (save_machine_status)
     (*save_machine_status) (p);
@@ -715,7 +714,6 @@ pop_function_context_from (context)
   restore_storage_status (p);
   restore_expr_status (p);
   restore_emit_status (p);
-  restore_stmt_status (p);
   restore_varasm_status (p);
 
   if (restore_machine_status)
index 03ff02fbc0372f3ef6c48395af4a80c115999f68..3d3943a4c428326d44622083013d12328056c439 100644 (file)
@@ -68,6 +68,7 @@ struct function
   struct function *next;
 
   struct eh_status *eh;
+  struct stmt_status *stmt;
 
   /* For function.c.  */
   char *name;
@@ -124,22 +125,6 @@ struct function
   struct var_refs_queue *fixup_var_refs_queue;
   CUMULATIVE_ARGS args_info;
 
-  /* For stmt.c  */
-  struct nesting *block_stack;
-  struct nesting *stack_block_stack;
-  struct nesting *cond_stack;
-  struct nesting *loop_stack;
-  struct nesting *case_stack;
-  struct nesting *nesting_stack;
-  int nesting_depth;
-  int block_start_count;
-  tree last_expr_type;
-  rtx last_expr_value;
-  int expr_stmts_for_value;
-  char *emit_filename;
-  int emit_lineno;
-  struct goto_fixup *goto_fixup_chain;
-
   /* For expr.c.  */
   rtx pending_chain;
   int pending_stack_adjust;
@@ -278,10 +263,6 @@ extern void save_tree_status               PROTO((struct function *, tree));
 extern void restore_tree_status                PROTO((struct function *, tree));
 extern void save_varasm_status         PROTO((struct function *, tree));
 extern void restore_varasm_status      PROTO((struct function *));
-extern void save_eh_status             PROTO((struct function *));
-extern void restore_eh_status          PROTO((struct function *));
-extern void save_stmt_status           PROTO((struct function *));
-extern void restore_stmt_status                PROTO((struct function *));
 extern void save_expr_status           PROTO((struct function *));
 extern void restore_expr_status                PROTO((struct function *));
 extern void save_emit_status           PROTO((struct function *));
index 520fa820898d4568518f21b88f877dc44c969adb..9b86a84e75b01d68e5302d4877c458654da3a7b7 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1464,6 +1464,7 @@ extern int operands_match_p               PROTO ((rtx, rtx));
 extern int safe_from_earlyclobber      PROTO ((rtx, rtx));
 
 /* In stmt.c */
+extern void set_file_and_line_for_stmt PROTO ((char *, int));
 extern void expand_null_return         PROTO((void));
 extern void emit_jump                  PROTO ((rtx));
 extern int preserve_subexpressions_p   PROTO ((void));
index ad76d88b460539093b29a22cd708e722b715c49b..62cfee0daf96276ec6c4d3865f3b076239d58742 100644 (file)
@@ -62,32 +62,12 @@ struct obstack stmt_obstack;
 #define CASE_VECTOR_PC_RELATIVE 0
 #endif
 
-/* Filename and line number of last line-number note,
-   whether we actually emitted it or not.  */
-char *emit_filename;
-int emit_lineno;
-
-/* Nonzero if within a ({...}) grouping, in which case we must
-   always compute a value for each expr-stmt in case it is the last one.  */
-
-int expr_stmts_for_value;
-
-/* Each time we expand an expression-statement,
-   record the expr's type and its RTL value here.  */
-
-static tree last_expr_type;
-static rtx last_expr_value;
-
 /* Each time we expand the end of a binding contour (in `expand_end_bindings')
    and we emit a new NOTE_INSN_BLOCK_END note, we save a pointer to it here.
    This is used by the `remember_end_note' function to record the endpoint
    of each generated block in its associated BLOCK node.  */
 
 static rtx last_block_end_note;
-
-/* Number of binding contours started so far in this function.  */
-
-int block_start_count;
 \f
 /* Functions and data structures for expanding case statements.  */
 
@@ -223,7 +203,7 @@ struct nesting
             For contours that have stack levels or cleanups.  */
          struct label_chain *label_chain;
          /* Number of function calls seen, as of start of this block.  */
-         int function_call_count;
+         int n_function_calls;
          /* Nonzero if this is associated with a EH region.  */
          int exception_region;
          /* The saved target_temp_slot_level from our outer block.
@@ -231,7 +211,7 @@ struct nesting
             this block, if that is done, target_temp_slot_level
             reverts to the saved target_temp_slot_level at the very
             end of the block.  */
-         int target_temp_slot_level;
+         int block_target_temp_slot_level;
          /* True if we are currently emitting insns in an area of
             output code that is controlled by a conditional
             expression.  This is used by the cleanup handling code to
@@ -276,31 +256,6 @@ struct nesting
     } data;
 };
 
-/* Chain of all pending binding contours.  */
-struct nesting *block_stack;
-
-/* If any new stacks are added here, add them to POPSTACKS too.  */
-
-/* Chain of all pending binding contours that restore stack levels
-   or have cleanups.  */
-struct nesting *stack_block_stack;
-
-/* Chain of all pending conditional statements.  */
-struct nesting *cond_stack;
-
-/* Chain of all pending loops.  */
-struct nesting *loop_stack;
-
-/* Chain of all pending case or switch statements.  */
-struct nesting *case_stack;
-
-/* Separate chain including all of the above,
-   chained through the `all' field.  */
-struct nesting *nesting_stack;
-
-/* Number of entries on nesting_stack now.  */
-int nesting_depth;
-
 /* Allocate and return a new `struct nesting'.  */
 
 #define ALLOC_NESTING() \
@@ -369,8 +324,6 @@ struct goto_fixup
   tree cleanup_list_list;
 };
 
-static struct goto_fixup *goto_fixup_chain;
-
 /* Within any binding contour that must restore a stack level,
    all labels are recorded with a chain of these structures.  */
 
@@ -381,6 +334,67 @@ struct label_chain
   tree label;
 };
 
+struct stmt_status
+{
+  /* Chain of all pending binding contours.  */
+  struct nesting *x_block_stack;
+
+  /* If any new stacks are added here, add them to POPSTACKS too.  */
+
+  /* Chain of all pending binding contours that restore stack levels
+     or have cleanups.  */
+  struct nesting *x_stack_block_stack;
+
+  /* Chain of all pending conditional statements.  */
+  struct nesting *x_cond_stack;
+
+  /* Chain of all pending loops.  */
+  struct nesting *x_loop_stack;
+
+  /* Chain of all pending case or switch statements.  */
+  struct nesting *x_case_stack;
+
+  /* Separate chain including all of the above,
+     chained through the `all' field.  */
+  struct nesting *x_nesting_stack;
+
+  /* Number of entries on nesting_stack now.  */
+  int x_nesting_depth;
+
+  /* Number of binding contours started so far in this function.  */
+  int x_block_start_count;
+
+  /* Each time we expand an expression-statement,
+     record the expr's type and its RTL value here.  */
+  tree x_last_expr_type;
+  rtx x_last_expr_value;
+
+  /* Nonzero if within a ({...}) grouping, in which case we must
+     always compute a value for each expr-stmt in case it is the last one.  */
+  int x_expr_stmts_for_value;
+
+  /* Filename and line number of last line-number note,
+     whether we actually emitted it or not.  */
+  char *x_emit_filename;
+  int x_emit_lineno;
+
+  struct goto_fixup *x_goto_fixup_chain;
+};
+
+#define block_stack (current_function->stmt->x_block_stack)
+#define stack_block_stack (current_function->stmt->x_stack_block_stack)
+#define cond_stack (current_function->stmt->x_cond_stack)
+#define loop_stack (current_function->stmt->x_loop_stack)
+#define case_stack (current_function->stmt->x_case_stack)
+#define nesting_stack (current_function->stmt->x_nesting_stack)
+#define nesting_depth (current_function->stmt->x_nesting_depth)
+#define current_block_start_count (current_function->stmt->x_block_start_count)
+#define last_expr_type (current_function->stmt->x_last_expr_type)
+#define last_expr_value (current_function->stmt->x_last_expr_value)
+#define expr_stmts_for_value (current_function->stmt->x_expr_stmts_for_value)
+#define emit_filename (current_function->stmt->x_emit_filename)
+#define emit_lineno (current_function->stmt->x_emit_lineno)
+#define goto_fixup_chain (current_function->stmt->x_goto_fixup_chain)
 
 /* Non-zero if we are using EH to handle cleanus.  */
 static int using_eh_for_cleanups_p = 0;
@@ -428,6 +442,9 @@ init_stmt ()
 void
 init_stmt_for_function ()
 {
+  current_function->stmt
+    = (struct stmt_status *) xmalloc (sizeof (struct stmt_status));
+
   /* We are not currently within any block, conditional, loop or case.  */
   block_stack = 0;
   stack_block_stack = 0;
@@ -437,7 +454,7 @@ init_stmt_for_function ()
   nesting_stack = 0;
   nesting_depth = 0;
 
-  block_start_count = 0;
+  current_block_start_count = 0;
 
   /* No gotos have been expanded yet.  */
   goto_fixup_chain = 0;
@@ -448,47 +465,25 @@ init_stmt_for_function ()
 
   init_eh_for_function ();
 }
-
-void
-save_stmt_status (p)
-     struct function *p;
+\f
+/* Return nonzero if anything is pushed on the loop, condition, or case
+   stack.  */
+int
+in_control_zone_p ()
 {
-  p->block_stack = block_stack;
-  p->stack_block_stack = stack_block_stack;
-  p->cond_stack = cond_stack;
-  p->loop_stack = loop_stack;
-  p->case_stack = case_stack;
-  p->nesting_stack = nesting_stack;
-  p->nesting_depth = nesting_depth;
-  p->block_start_count = block_start_count;
-  p->last_expr_type = last_expr_type;
-  p->last_expr_value = last_expr_value;
-  p->expr_stmts_for_value = expr_stmts_for_value;
-  p->emit_filename = emit_filename;
-  p->emit_lineno = emit_lineno;
-  p->goto_fixup_chain = goto_fixup_chain;
+  return cond_stack || loop_stack || case_stack;
 }
 
+/* Record the current file and line.  Called from emit_line_note.  */
 void
-restore_stmt_status (p)
-     struct function *p;
+set_file_and_line_for_stmt (file, line)
+     char *file;
+     int line;
 {
-  block_stack = p->block_stack;
-  stack_block_stack = p->stack_block_stack;
-  cond_stack = p->cond_stack;
-  loop_stack = p->loop_stack;
-  case_stack = p->case_stack;
-  nesting_stack = p->nesting_stack;
-  nesting_depth = p->nesting_depth;
-  block_start_count = p->block_start_count;
-  last_expr_type = p->last_expr_type;
-  last_expr_value = p->last_expr_value;
-  expr_stmts_for_value = p->expr_stmts_for_value;
-  emit_filename = p->emit_filename;
-  emit_lineno = p->emit_lineno;
-  goto_fixup_chain = p->goto_fixup_chain;
+  emit_filename = file;
+  emit_lineno = line;
 }
-\f
+
 /* Emit a no-op instruction.  */
 
 void
@@ -878,7 +873,7 @@ expand_fixup (tree_label, rtl_label, last_insn)
         emit_insns_after (start, original_before_jump);
       }
 
-      fixup->block_start_count = block_start_count;
+      fixup->block_start_count = current_block_start_count;
       fixup->stack_level = 0;
       fixup->cleanup_list_list
        = ((block->data.block.outer_cleanups
@@ -2437,7 +2432,7 @@ preserve_subexpressions_p ()
   if (flag_expensive_optimizations)
     return 1;
 
-  if (optimize == 0 || loop_stack == 0)
+  if (optimize == 0 || current_function == 0 || loop_stack == 0)
     return 0;
 
   insn = get_last_insn_anywhere ();
@@ -3019,9 +3014,9 @@ expand_start_bindings (exit_flag)
   thisblock->depth = ++nesting_depth;
   thisblock->data.block.stack_level = 0;
   thisblock->data.block.cleanups = 0;
-  thisblock->data.block.function_call_count = 0;
+  thisblock->data.block.n_function_calls = 0;
   thisblock->data.block.exception_region = 0;
-  thisblock->data.block.target_temp_slot_level = target_temp_slot_level;
+  thisblock->data.block.block_target_temp_slot_level = target_temp_slot_level;
 
   thisblock->data.block.conditional_code = 0;
   thisblock->data.block.last_unconditional_cleanup = note;
@@ -3038,7 +3033,7 @@ expand_start_bindings (exit_flag)
   thisblock->data.block.label_chain = 0;
   thisblock->data.block.innermost_stack_block = stack_block_stack;
   thisblock->data.block.first_insn = note;
-  thisblock->data.block.block_start_count = ++block_start_count;
+  thisblock->data.block.block_start_count = ++current_block_start_count;
   thisblock->exit_label = exit_flag ? gen_label_rtx () : 0;
   block_stack = thisblock;
   nesting_stack = thisblock;
@@ -3365,7 +3360,7 @@ expand_end_bindings (vars, mark_ends, dont_jump_in)
 
   /* If necessary, make handlers for nonlocal gotos taking
      place in the function calls in this block.  */
-  if (function_call_count != thisblock->data.block.function_call_count
+  if (function_call_count != thisblock->data.block.n_function_calls
       && nonlocal_labels
       /* Make handler for outermost block
         if there were any nonlocal gotos to this function.  */
@@ -3462,7 +3457,7 @@ expand_end_bindings (vars, mark_ends, dont_jump_in)
        use_variable (DECL_RTL (decl));
 
   /* Restore the temporary level of TARGET_EXPRs.  */
-  target_temp_slot_level = thisblock->data.block.target_temp_slot_level;
+  target_temp_slot_level = thisblock->data.block.block_target_temp_slot_level;
 
   /* Restore block_stack level for containing block.  */
 
@@ -3480,7 +3475,7 @@ void
 expand_decl (decl)
      register tree decl;
 {
-  struct nesting *thisblock = block_stack;
+  struct nesting *thisblock;
   tree type;
 
   type = TREE_TYPE (decl);
@@ -3496,6 +3491,8 @@ expand_decl (decl)
   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
     return;
 
+  thisblock = block_stack;
+
   /* Create the RTL representation for the variable.  */
 
   if (type == error_mark_node)
@@ -3722,12 +3719,14 @@ int
 expand_decl_cleanup (decl, cleanup)
      tree decl, cleanup;
 {
-  struct nesting *thisblock = block_stack;
+  struct nesting *thisblock;
 
   /* Error if we are not in any block.  */
-  if (thisblock == 0)
+  if (current_function == 0 || block_stack == 0)
     return 0;
 
+  thisblock = block_stack;
+
   /* Record the cleanup if there is one.  */
 
   if (cleanup != 0)
@@ -3851,12 +3850,13 @@ int
 expand_dcc_cleanup (decl)
      tree decl;
 {
-  struct nesting *thisblock = block_stack;
+  struct nesting *thisblock;
   tree cleanup;
 
   /* Error if we are not in any block.  */
-  if (thisblock == 0)
+  if (current_function == 0 || block_stack == 0)
     return 0;
+  thisblock = block_stack;
 
   /* Record the cleanup for the dynamic handler chain.  */
 
@@ -3892,12 +3892,13 @@ int
 expand_dhc_cleanup (decl)
      tree decl;
 {
-  struct nesting *thisblock = block_stack;
+  struct nesting *thisblock;
   tree cleanup;
 
   /* Error if we are not in any block.  */
-  if (thisblock == 0)
+  if (current_function == 0 || block_stack == 0)
     return 0;
+  thisblock = block_stack;
 
   /* Record the cleanup for the dynamic handler chain.  */
 
@@ -3924,7 +3925,7 @@ void
 expand_anon_union_decl (decl, cleanup, decl_elts)
      tree decl, cleanup, decl_elts;
 {
-  struct nesting *thisblock = block_stack;
+  struct nesting *thisblock = current_function == 0 ? 0 : block_stack;
   rtx x;
 
   expand_decl (decl);
index b16d73e398680f95a32b4798d6479ffd4407d484..7047f1d56549333330d918dd669870c5896dd3f7 100644 (file)
@@ -1929,6 +1929,7 @@ extern int (*lang_get_alias_set)                PROTO((tree));
 \f
 /* In stmt.c */
 
+extern int in_control_zone_p                   PROTO((void));
 extern void expand_fixups                      PROTO((struct rtx_def *));
 extern tree expand_start_stmt_expr             PROTO((void));
 extern tree expand_end_stmt_expr               PROTO((tree));