diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-20 09:26:52 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-20 09:26:52 +0100 |
commit | 06e8db10cd80d88fb3a6afedf2c35da6c1fa6d85 (patch) | |
tree | 63bfe92cbc1e4a74c4813954690d30c5e9542564 /gcc | |
parent | c04341ec45cf332e4f1a7057a6cdb461629275ab (diff) | |
download | gcc-06e8db10cd80d88fb3a6afedf2c35da6c1fa6d85.zip gcc-06e8db10cd80d88fb3a6afedf2c35da6c1fa6d85.tar.gz gcc-06e8db10cd80d88fb3a6afedf2c35da6c1fa6d85.tar.bz2 |
re PR middle-end/91195 (incorrect may be used uninitialized smw (272711, 273474])
PR middle-end/91195
* tree-ssa-phiopt.c (cond_store_replacement): Move lhs unsharing
earlier. Set TREE_NO_WARNING on the rhs1 of the artificially added
load.
* gcc.dg/pr91195.c: New test.
From-SVN: r278479
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr91195.c | 25 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 5 |
4 files changed, 42 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a833914..97bc515 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-11-20 Jiangning Liu <jiangning.liu@amperecomputing.com> + Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91195 + * tree-ssa-phiopt.c (cond_store_replacement): Move lhs unsharing + earlier. Set TREE_NO_WARNING on the rhs1 of the artificially added + load. + 2019-11-20 Georg-Johann Lay <avr@gjlay.de> Make 0-series device specs work with older versions of avr-gcc. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8198d22..920f8eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-20 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91195 + * gcc.dg/pr91195.c: New test. + 2019-11-20 Richard Biener <rguenther@suse.de> PR c/92088 diff --git a/gcc/testsuite/gcc.dg/pr91195.c b/gcc/testsuite/gcc.dg/pr91195.c new file mode 100644 index 0000000..ea3021d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91195.c @@ -0,0 +1,25 @@ +/* PR middle-end/91195 */ +/* { dg-do compile } */ +/* { dg-options "-Wmaybe-uninitialized -O2" } */ + +int bar (char*); + +void +foo (char *x, char *y) +{ + char *a[2]; + int b = 0; + + if (x) + a[b++] = x; /* { dg-bogus "may be used uninitialized in this function" } */ + if (y) + a[b++] = y; + + for (int j = 0; j < 4; j++) + switch (j) + { + case 0: + if (b == 0 || bar (a[0])) + break; + } +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index c2595c8..9058309 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -2269,6 +2269,10 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, name = make_temp_ssa_name (TREE_TYPE (lhs), NULL, "cstore"); new_stmt = gimple_build_assign (name, lhs); gimple_set_location (new_stmt, locus); + lhs = unshare_expr (lhs); + /* Set TREE_NO_WARNING on the rhs of the load to avoid uninit + warnings. */ + TREE_NO_WARNING (gimple_assign_rhs1 (new_stmt)) = 1; gsi_insert_on_edge (e1, new_stmt); /* 3) Create a PHI node at the join block, with one argument @@ -2279,7 +2283,6 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, add_phi_arg (newphi, rhs, e0, locus); add_phi_arg (newphi, name, e1, locus); - lhs = unshare_expr (lhs); new_stmt = gimple_build_assign (lhs, PHI_RESULT (newphi)); /* 4) Insert that PHI node. */ |