diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-05-02 11:55:32 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2012-05-02 11:55:32 +0200 |
commit | 795e8869fd8be77f9221f1b3884b228601f7c7d6 (patch) | |
tree | 29483f94c7fd8e951808091e6445ac4ed0428961 /gcc | |
parent | 6aae324cce99057e81876888e5f83e20bad9f55d (diff) | |
download | gcc-795e8869fd8be77f9221f1b3884b228601f7c7d6.zip gcc-795e8869fd8be77f9221f1b3884b228601f7c7d6.tar.gz gcc-795e8869fd8be77f9221f1b3884b228601f7c7d6.tar.bz2 |
re PR tree-optimization/53163 (crash due to null ptr deref)
PR tree-optimization/53163
* tree-ssa-phiopt.c (cond_if_else_store_replacement): Don't ignore
return value from compute_all_dependences.
* gcc.c-torture/compile/pr53163.c: New test.
From-SVN: r187038
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr53163.c | 34 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 13 |
4 files changed, 52 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 972f3cc..f9b8a6e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2012-05-02 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/53163 + * tree-ssa-phiopt.c (cond_if_else_store_replacement): Don't ignore + return value from compute_all_dependences. + PR rtl-optimization/53160 * ree.c (combine_reaching_defs): Handle the case where cand->insn has been modified by ree pass already. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 72d9379..b205543 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-05-02 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/53163 + * gcc.c-torture/compile/pr53163.c: New test. + PR rtl-optimization/53160 * gcc.c-torture/execute/pr53160.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr53163.c b/gcc/testsuite/gcc.c-torture/compile/pr53163.c new file mode 100644 index 0000000..990b113 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr53163.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/53163 */ + +struct S { int s; } b, f; +int a, c; + +void +foo (void) +{ + int d, e; + for (d = 4; d < 19; ++d) + for (e = 2; e >= 0; e--) + { + a = 0; + a = 1; + } +} + +void +bar (void) +{ + int g, h, i; + for (i = 1; i >= 0; i--) + { + b = f; + for (g = 0; g <= 1; g++) + { + if (c) + break; + for (h = 0; h <= 1; h++) + foo (); + foo (); + } + } +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 88c16e6..1cfa0f5 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1624,8 +1624,17 @@ cond_if_else_store_replacement (basic_block then_bb, basic_block else_bb, /* Compute and check data dependencies in both basic blocks. */ then_ddrs = VEC_alloc (ddr_p, heap, 1); else_ddrs = VEC_alloc (ddr_p, heap, 1); - compute_all_dependences (then_datarefs, &then_ddrs, NULL, false); - compute_all_dependences (else_datarefs, &else_ddrs, NULL, false); + if (!compute_all_dependences (then_datarefs, &then_ddrs, NULL, false) + || !compute_all_dependences (else_datarefs, &else_ddrs, NULL, false)) + { + free_dependence_relations (then_ddrs); + free_dependence_relations (else_ddrs); + free_data_refs (then_datarefs); + free_data_refs (else_datarefs); + VEC_free (gimple, heap, then_stores); + VEC_free (gimple, heap, else_stores); + return false; + } blocks[0] = then_bb; blocks[1] = else_bb; blocks[2] = join_bb; |