diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-29 15:47:19 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-29 15:47:19 +0000 |
commit | ed6049c8d4abb6da11e251490ff3ca6d3c1cada4 (patch) | |
tree | 7b6cda1d150280c50f4c6d2bbb388db41dc4fa4d | |
parent | 830a6615b11231355af6fbe3ac324301b7014e2f (diff) | |
download | gcc-ed6049c8d4abb6da11e251490ff3ca6d3c1cada4.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131939 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr35006.c | 29 | ||||
-rw-r--r-- | gcc/tree-inline.c | 14 | ||||
-rw-r--r-- | gcc/tree-inline.h | 3 |
5 files changed, 57 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a827f0df4f5..cb097d93c94 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 832e1e87b61..86bfcc7a34b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35006.c b/gcc/testsuite/gcc.c-torture/compile/pr35006.c new file mode 100644 index 00000000000..53de05cdb40 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr35006.c @@ -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); +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 636e37d8024..d2ef9619eb2 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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. diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h index 893b9c9d0ce..562713a3299 100644 --- a/gcc/tree-inline.h +++ b/gcc/tree-inline.h @@ -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; |