re PR tree-optimization/35006 (Segfault in remove_unused_locals with nested functions)

2008-01-29  Richard Guenther  <rguenther@suse.de>

	PR middle-end/35006
	* tree-inline.h (struct copy_body_data): Add remapping_type_depth
	field.
	* tree-inline.c (remap_type): Increment remapping_type_depth
	around remapping types.
	(copy_body_r): Only add referenced variables if they are referenced
	from code, not types.

	* gcc.c-torture/compile/pr35006.c: New testcase.

From-SVN: r131939
This commit is contained in:
Richard Guenther 2008-01-29 15:47:19 +00:00 committed by Richard Biener
parent 7b3e2d465d
commit 4f5c64b8ac
5 changed files with 57 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2008-01-29 Richard Guenther <rguenther@suse.de>
PR middle-end/35006
* tree-inline.h (struct copy_body_data): Add remapping_type_depth
field.
* tree-inline.c (remap_type): Increment remapping_type_depth
around remapping types.
(copy_body_r): Only add referenced variables if they are referenced
from code, not types.
2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34055

View File

@ -1,3 +1,8 @@
2008-01-29 Richard Guenther <rguenther@suse.de>
PR middle-end/35006
* gcc.c-torture/compile/pr35006.c: New testcase.
2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34055

View File

@ -0,0 +1,29 @@
typedef unsigned long grub_uint64_t;
typedef grub_uint64_t grub_size_t;
grub_cmdline_get (unsigned max_len, int echo_char)
{
unsigned xpos, ypos, ystart;
grub_size_t lpos, llen;
char buf[max_len];
void cl_print (int pos, int c)
{
char *p;
for (p = buf + pos; *p; p++)
{
if (xpos++ > 78)
grub_putchar ('\n');
grub_putchar (*p);
}
}
void cl_delete (unsigned len)
{
cl_set_pos ();
cl_print (lpos, ' ');
grub_memmove ();
cl_print (lpos, echo_char);
cl_set_pos ();
}
cl_delete (llen);
grub_size_t n = lpos;
cl_delete (n);
}

View File

@ -409,6 +409,7 @@ tree
remap_type (tree type, copy_body_data *id)
{
tree *node;
tree tmp;
if (type == NULL)
return type;
@ -425,7 +426,11 @@ remap_type (tree type, copy_body_data *id)
return type;
}
return remap_type_1 (type, id);
id->remapping_type_depth++;
tmp = remap_type_1 (type, id);
id->remapping_type_depth--;
return tmp;
}
static tree
@ -723,9 +728,10 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
tweak some special cases. */
copy_tree_r (tp, walk_subtrees, NULL);
/* Global variables we didn't seen yet needs to go into referenced
vars. */
if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL)
/* Global variables we haven't seen yet needs to go into referenced
vars. If not referenced from types only. */
if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL
&& id->remapping_type_depth == 0)
add_referenced_var (*tp);
/* If EXPR has block defined, map it to newly constructed block.

View File

@ -95,6 +95,9 @@ typedef struct copy_body_data
/* True if this statement will need to be regimplified. */
bool regimplify;
/* > 0 if we are remapping a type currently. */
int remapping_type_depth;
/* Statements that might be possibly folded. */
struct pointer_set_t *statements_to_fold;