This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][4.4] Fix PR42773
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jakub Jelinek <jakub at redhat dot com>
- Date: Sun, 17 Jan 2010 15:03:32 +0100 (CET)
- Subject: [PATCH][4.4] Fix PR42773
This fixes PR42773 a regression from 4.4.2 caused by a wrong way
to check for the existance of PHI nodes. It seems to be a common
pattern, so I'll go over the rest in the 4.5 tree.
Bootstrap and testing running on x86_64-unknown-linux-gnu,
ok for 4.4.3?
Thanks,
Richard.
2010-01-17 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42773
* tree-ssa-pre.c (phi_translate_set): Fix check for PHI node existance.
(compute_antic_aux): Likewise.
(compute_partial_antic_aux): Likewise.
* g++.dg/torture/pr42773.C: New testcase.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c (revision 155978)
--- gcc/tree-ssa-pre.c (working copy)
*************** phi_translate_set (bitmap_set_t dest, bi
*** 1718,1724 ****
pre_expr expr;
int i;
! if (!phi_nodes (phiblock))
{
bitmap_set_copy (dest, set);
return;
--- 1718,1724 ----
pre_expr expr;
int i;
! if (gimple_seq_empty_p (phi_nodes (phiblock)))
{
bitmap_set_copy (dest, set);
return;
*************** compute_antic_aux (basic_block block, bo
*** 2100,2113 ****
goto maybe_dump_sets;
}
! if (phi_nodes (first))
phi_translate_set (ANTIC_OUT, ANTIC_IN (first), block, first);
else
bitmap_set_copy (ANTIC_OUT, ANTIC_IN (first));
for (i = 0; VEC_iterate (basic_block, worklist, i, bprime); i++)
{
! if (phi_nodes (bprime))
{
bitmap_set_t tmp = bitmap_set_new ();
phi_translate_set (tmp, ANTIC_IN (bprime), block, bprime);
--- 2100,2113 ----
goto maybe_dump_sets;
}
! if (!gimple_seq_empty_p (phi_nodes (first)))
phi_translate_set (ANTIC_OUT, ANTIC_IN (first), block, first);
else
bitmap_set_copy (ANTIC_OUT, ANTIC_IN (first));
for (i = 0; VEC_iterate (basic_block, worklist, i, bprime); i++)
{
! if (!gimple_seq_empty_p (phi_nodes (bprime)))
{
bitmap_set_t tmp = bitmap_set_new ();
phi_translate_set (tmp, ANTIC_IN (bprime), block, bprime);
*************** compute_partial_antic_aux (basic_block b
*** 2257,2263 ****
FOR_EACH_EXPR_ID_IN_SET (ANTIC_IN (bprime), i, bi)
bitmap_value_insert_into_set (PA_OUT,
expression_for_id (i));
! if (phi_nodes (bprime))
{
bitmap_set_t pa_in = bitmap_set_new ();
phi_translate_set (pa_in, PA_IN (bprime), block, bprime);
--- 2257,2263 ----
FOR_EACH_EXPR_ID_IN_SET (ANTIC_IN (bprime), i, bi)
bitmap_value_insert_into_set (PA_OUT,
expression_for_id (i));
! if (!gimple_seq_empty_p (phi_nodes (bprime)))
{
bitmap_set_t pa_in = bitmap_set_new ();
phi_translate_set (pa_in, PA_IN (bprime), block, bprime);
Index: gcc/testsuite/g++.dg/torture/pr42773.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr42773.C (revision 0)
--- gcc/testsuite/g++.dg/torture/pr42773.C (revision 0)
***************
*** 0 ****
--- 1,54 ----
+ // { dg-do compile }
+ // { dg-options "-fno-exceptions" }
+
+ typedef unsigned int uint;
+ struct QShared {
+ bool deref() {
+ return !--count;
+ }
+ uint count;
+ };
+ template <class T> class QValueListNode {
+ public:
+ QValueListNode<T>* next;
+ QValueListNode<T>* prev;
+ };
+ template <class T> class QValueListPrivate : public QShared {
+ public:
+ typedef QValueListNode<T> Node;
+ typedef QValueListNode<T>* NodePtr;
+ QValueListPrivate();
+ void derefAndDelete() {
+ if ( deref() ) delete this;
+ }
+ ~QValueListPrivate();
+ NodePtr node;
+ };
+ template <class T> QValueListPrivate<T>::QValueListPrivate() {
+ node = new Node;
+ node->next = node->prev = node;
+ }
+ template <class T> QValueListPrivate<T>::~QValueListPrivate() {
+ NodePtr p = node->next;
+ while( p != node ) {
+ NodePtr x = p->next;
+ delete p;
+ p = x;
+ }
+ }
+ template <class T> class QValueList {
+ public:
+ QValueList() {
+ sh = new QValueListPrivate<T>;
+ }
+ ~QValueList() {
+ sh->derefAndDelete();
+ }
+ QValueListPrivate<T>* sh;
+ };
+ class Cell {
+ QValueList<Cell*> obscuringCells() const;
+ };
+ QValueList<Cell*> Cell::obscuringCells() const {
+ QValueList<Cell*> empty;
+ }