From 649fa1dcb75c430763e8823e39109ca4e2f71811 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 30 Aug 2010 11:13:05 +0000 Subject: [PATCH] 2010-08-30 Richard Guenther PR tree-optimization/45449 * tree-ssa-live.c (remove_unused_locals): Also remove address-taken variables. * gcc.dg/pr45449.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163638 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr45449.c | 22 ++++++++++++++++++++++ gcc/tree-ssa-live.c | 9 ++------- 4 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr45449.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 37106bff884..e4e5f4c2981 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-08-30 Richard Guenther + + PR tree-optimization/45449 + * tree-ssa-live.c (remove_unused_locals): Also remove address-taken + variables. + 2010-08-30 Joseph Myers * opts.h (CL_ERR_NEGATIVE): Define. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 984c2f45ef2..f01e477c3c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-08-30 Richard Guenther + + PR tree-optimization/45449 + * gcc.dg/pr45449.c: New testcase. + 2010-08-30 Joseph Myers * gcc.dg/opts-1.c: Expect errors, not warnings. diff --git a/gcc/testsuite/gcc.dg/pr45449.c b/gcc/testsuite/gcc.dg/pr45449.c new file mode 100644 index 00000000000..d7b69a1827e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr45449.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-pre -fno-tree-pta -fcompare-debug" } */ + +struct S +{ +}; + +void +baz (void) +{ + struct S s; + &s; +} + +int bar (void); + +void +foo (void) +{ + if (bar ()) + baz (); +} diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 1eb68221495..821be7f2a8e 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -813,18 +813,13 @@ remove_unused_locals (void) BITMAP_FREE (global_unused_vars); } - /* Remove unused variables from REFERENCED_VARs. As a special - exception keep the variables that are believed to be aliased. - Those can't be easily removed from the alias sets and operand - caches. They will be removed shortly after the next may_alias - pass is performed. */ + /* Remove unused variables from REFERENCED_VARs. */ FOR_EACH_REFERENCED_VAR (t, rvi) if (!is_global_var (t) && TREE_CODE (t) != PARM_DECL && TREE_CODE (t) != RESULT_DECL && !(ann = var_ann (t))->used - && !ann->is_heapvar - && !TREE_ADDRESSABLE (t)) + && !ann->is_heapvar) remove_referenced_var (t); remove_unused_scope_block_p (DECL_INITIAL (current_function_decl)); if (dump_file && (dump_flags & TDF_DETAILS)) -- 2.11.4.GIT