2005-09-02 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2005 12:41:08 +0000 (12:41 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2005 12:41:08 +0000 (12:41 +0000)
        PR middle-end/23547
        * tree-nested.c (struct var_map_elt): Mark with GTY.
        (struct nesting_info): Mark with GTY.  Mark var_map's param is struct
        var_map_elt.
        (lookup_field_for_decl): Allocate new element in GC memory.
        (lookup_tramp_for_decl): Likewise.
        (convert_nl_goto_reference): Likewise
        (create_nesting_tree): Allocate info in GC memory. Likewise for        info->var_map.
        (free_nesting_tree): Free with ggc_free instead of free.
        (root): New static variable.
        (lower_nested_functions): Remove root as local variable.  And zero out        root at the end of the function.

2005-09-02  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/23547
        * gcc.dg/pr23547.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103777 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr23547.c [new file with mode: 0644]
gcc/tree-nested.c

index f240c5d..8c31315 100644 (file)
@@ -1,3 +1,19 @@
+2005-09-02  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/23547
+       * tree-nested.c (struct var_map_elt): Mark with GTY.
+       (struct nesting_info): Mark with GTY.  Mark var_map's param is struct
+       var_map_elt.
+       (lookup_field_for_decl): Allocate new element in GC memory.
+       (lookup_tramp_for_decl): Likewise.
+       (convert_nl_goto_reference): Likewise
+       (create_nesting_tree): Allocate info in GC memory. Likewise for
+       info->var_map.
+       (free_nesting_tree): Free with ggc_free instead of free.
+       (root): New static variable.
+       (lower_nested_functions): Remove root as local variable.  And zero out
+       root at the end of the function.
+
 2005-09-02  J"orn Rennecke <joern.rennecke@st.com>
 
        PR rtl-optimization/20365
index 515bd26..cfe3941 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-02  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/23547
+       * gcc.dg/pr23547.c: New test.
+
 2005-09-02  Richard Sandiford  <richard@codesourcery.com>
 
        PR c/22061
diff --git a/gcc/testsuite/gcc.dg/pr23547.c b/gcc/testsuite/gcc.dg/pr23547.c
new file mode 100644 (file)
index 0000000..210fae7
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */
+void foo()
+{
+  void bar()
+  {
+    bar();
+  }
+}
+
+void foo1(int i)
+{
+    void bar (char c[1][i]) { }
+}
index 45c9bfe..6f0b7fd 100644 (file)
    been written as independent functions without change.  */
 
 
-struct var_map_elt
+struct var_map_elt GTY(())
 {
   tree old;
   tree new;
 };
 
-struct nesting_info
+struct nesting_info GTY ((chain_next ("%h.next")))
 {
   struct nesting_info *outer;
   struct nesting_info *inner;
   struct nesting_info *next;
   
-  htab_t var_map;
+  htab_t GTY ((param_is (struct var_map_elt))) var_map;
   tree context;
   tree new_local_var_chain;
   tree frame_type;
@@ -288,7 +288,7 @@ lookup_field_for_decl (struct nesting_info *info, tree decl,
 
       insert_field_into_struct (get_frame_type (info), field);
   
-      elt = xmalloc (sizeof (*elt));
+      elt = ggc_alloc (sizeof (*elt));
       elt->old = decl;
       elt->new = field;
       *slot = elt;
@@ -474,7 +474,7 @@ lookup_tramp_for_decl (struct nesting_info *info, tree decl,
 
       insert_field_into_struct (get_frame_type (info), field);
 
-      elt = xmalloc (sizeof (*elt));
+      elt = ggc_alloc (sizeof (*elt));
       elt->old = decl;
       elt->new = field;
       *slot = elt;
@@ -698,8 +698,8 @@ check_for_nested_with_variably_modified (tree fndecl, tree orig_fndecl)
 static struct nesting_info *
 create_nesting_tree (struct cgraph_node *cgn)
 {
-  struct nesting_info *info = xcalloc (1, sizeof (*info));
-  info->var_map = htab_create (7, var_map_hash, var_map_eq, free);
+  struct nesting_info *info = ggc_calloc (1, sizeof (*info));
+  info->var_map = htab_create_ggc (7, var_map_hash, var_map_eq, ggc_free);
   info->context = cgn->decl;
 
   for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
@@ -1108,7 +1108,7 @@ convert_nl_goto_reference (tree *tp, int *walk_subtrees, void *data)
 
   /* Enter this association into var_map so that we can insert the new
      label into the IL during a second pass.  */
-  elt = xmalloc (sizeof (*elt));
+  elt = ggc_alloc (sizeof (*elt));
   elt->old = label;
   elt->new = new_label;
   slot = htab_find_slot (i->var_map, elt, INSERT);
@@ -1474,19 +1474,20 @@ free_nesting_tree (struct nesting_info *root)
        free_nesting_tree (root->inner);
       htab_delete (root->var_map);
       next = root->next;
-      free (root);
+      ggc_free (root);
       root = next;
     }
   while (root);
 }
 
+static GTY(()) struct nesting_info *root;
+
 /* Main entry point for this pass.  Process FNDECL and all of its nested
    subroutines and turn them into something less tightly bound.  */
 
 void
 lower_nested_functions (tree fndecl)
 {
-  struct nesting_info *root;
   struct cgraph_node *cgn;
 
   /* If there are no nested functions, there's nothing to do.  */
@@ -1502,6 +1503,7 @@ lower_nested_functions (tree fndecl)
   convert_all_function_calls (root);
   finalize_nesting_tree (root);
   free_nesting_tree (root);
+  root = NULL;
 }
 
 #include "gt-tree-nested.h"