re PR middle-end/23547 ([non-unit-at-a-time] ICE with recursive call to nested function)

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  Andrew Pinski  <pinskia@physics.uc.edu>

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

From-SVN: r103777
This commit is contained in:
Andrew Pinski 2005-09-02 12:41:08 +00:00 committed by Andrew Pinski
parent b8d7f9febc
commit 9bf777eedf
4 changed files with 47 additions and 10 deletions

View 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

View 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

View File

@ -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]) { }
}

View File

@ -77,19 +77,19 @@
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"