diff options
author | Patrick Palka <ppalka@gcc.gnu.org> | 2014-11-10 20:43:40 +0000 |
---|---|---|
committer | Patrick Palka <ppalka@gcc.gnu.org> | 2014-11-10 20:43:40 +0000 |
commit | c7488fba456957f70edd5a6bb0464fe336f694c5 (patch) | |
tree | 5775c1e9ec86f3e40c0415ce897655efa09b8992 | |
parent | 3bbddc8e442eab7b76a5c1a0f63ef5fc647423e0 (diff) | |
download | gcc-c7488fba456957f70edd5a6bb0464fe336f694c5.zip gcc-c7488fba456957f70edd5a6bb0464fe336f694c5.tar.gz gcc-c7488fba456957f70edd5a6bb0464fe336f694c5.tar.bz2 |
re PR tree-optimization/63748 (wrong may be used uninitialized warning (abnormal edges))
2014-11-10 Patrick Palka <ppalka@gcc.gnu.org>
gcc/
PR middle-end/63748
* tree-ssa-propagate.c (may_propagate_copy): Allow propagating
SSA copies whose source and destination names both occur in
abnormal PHIs.
gcc/testsuite/
PR middle-end/63748
* gcc.dg/pr63748.c: New testcase.
From-SVN: r217317
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr63748.c | 36 | ||||
-rw-r--r-- | gcc/tree-ssa-propagate.c | 27 |
4 files changed, 63 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6ad4342..8a32922 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-11-10 Patrick Palka <ppalka@gcc.gnu.org> + + PR middle-end/63748 + * tree-ssa-propagate.c (may_propagate_copy): Allow propagating + SSA copies whose source and destination names both occur in + abnormal PHIs. + 2014-11-10 Roman Gareev <gareevroman@gmail.com> * Makefile.in: Remove the compilation of graphite-clast-to-gimple.o. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a9cb2d0..812696d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-10 Patrick Palka <ppalka@gcc.gnu.org> + + PR middle-end/63748 + * gcc.dg/pr63748.c: New testcase. + 2014-11-10 H.J. Lu <hongjiu.lu@intel.com> * gcc.dg/pr44194-1.c (dg-do): Add missing braces. diff --git a/gcc/testsuite/gcc.dg/pr63748.c b/gcc/testsuite/gcc.dg/pr63748.c new file mode 100644 index 0000000..2e50445 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr63748.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +#include <setjmp.h> + +jmp_buf *alloc_jmp_buf (); +int foo (void *); + +int +test (int op, int noside) +{ + void *argvec = 0; + + if (op) + { + jmp_buf *buf = alloc_jmp_buf (); /* { dg-bogus "uninitialized" } */ + setjmp (*buf); + + if (noside) + goto nosideret; + + do_call_it: + + if (noside) + goto nosideret; + + return foo (argvec); + } + + argvec = __builtin_alloca (1); + goto do_call_it; + +nosideret: + return 1; +} + diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 9f4d381..0195afa 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1275,21 +1275,24 @@ may_propagate_copy (tree dest, tree orig) tree type_d = TREE_TYPE (dest); tree type_o = TREE_TYPE (orig); - /* If ORIG flows in from an abnormal edge, it cannot be propagated. */ + /* If ORIG is a default definition which flows in from an abnormal edge + then the copy can be propagated. It is important that we do so to avoid + uninitialized copies. */ if (TREE_CODE (orig) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig) - /* If it is the default definition and an automatic variable then - we can though and it is important that we do to avoid - uninitialized regular copies. */ - && !(SSA_NAME_IS_DEFAULT_DEF (orig) - && (SSA_NAME_VAR (orig) == NULL_TREE - || TREE_CODE (SSA_NAME_VAR (orig)) == VAR_DECL))) + && SSA_NAME_IS_DEFAULT_DEF (orig) + && (SSA_NAME_VAR (orig) == NULL_TREE + || TREE_CODE (SSA_NAME_VAR (orig)) == VAR_DECL)) + ; + /* Otherwise if ORIG just flows in from an abnormal edge then the copy cannot + be propagated. */ + else if (TREE_CODE (orig) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)) return false; - - /* If DEST is an SSA_NAME that flows from an abnormal edge, then it - cannot be replaced. */ - if (TREE_CODE (dest) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest)) + /* Similarly if DEST flows in from an abnormal edge then the copy cannot be + propagated. */ + else if (TREE_CODE (dest) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest)) return false; /* Do not copy between types for which we *do* need a conversion. */ |