This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 18501: Run uninitialized warnings pass before DCE
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 17 Dec 2004 17:18:40 -0500
- Subject: Re: PR 18501: Run uninitialized warnings pass before DCE
- Organization: Red Hat Canada
- References: <41C35412.3040901@redhat.com> <20041217215429.GA13865@redhat.com>
Richard Henderson wrote:
Probably not too bad, and probably still better results
than some earlier 3.x releases.
OK, I've xfailed the other tests and opened and enhancement PR. I will
be committing this patch. Bootstrapped and tested x86, x86-64, alpha
and ppc.
Diego.
2004-12-17 Diego Novillo <dnovillo@redhat.com>
tree-optimization/18501
* tree-optimize.c (init_tree_optimization_passes): Run
pass_late_warn_uninitialized before the last DCE run.
testsuite/ChangeLog:
* gcc.dg/pr18501.c: New test.
* gcc.dg/uninit-5.c: XFAIL.
* gcc.dg/uninit-9.c: XFAIL.
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.65
diff -d -c -p -u -r2.65 tree-optimize.c
--- tree-optimize.c 30 Nov 2004 15:38:33 -0000 2.65
+++ tree-optimize.c 17 Dec 2004 22:14:39 -0000
@@ -381,12 +381,21 @@ init_tree_optimization_passes (void)
NEXT_PASS (pass_loop);
NEXT_PASS (pass_dominator);
NEXT_PASS (pass_redundant_phi);
+ /* FIXME: If DCE is not run before checking for uninitialized uses,
+ we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
+ However, this also causes us to misdiagnose cases that should be
+ real warnings (e.g., testsuite/gcc.dg/pr18501.c).
+
+ To fix the false positives in uninit-5.c, we would have to
+ account for the predicates protecting the set and the use of each
+ variable. Using a representation like Gated Single Assignment
+ may help. */
+ NEXT_PASS (pass_late_warn_uninitialized);
NEXT_PASS (pass_cd_dce);
NEXT_PASS (pass_dse);
NEXT_PASS (pass_forwprop);
NEXT_PASS (pass_phiopt);
NEXT_PASS (pass_tail_calls);
- NEXT_PASS (pass_late_warn_uninitialized);
NEXT_PASS (pass_del_ssa);
NEXT_PASS (pass_nrv);
NEXT_PASS (pass_remove_useless_vars);
Index: testsuite/gcc.dg/pr18501.c
===================================================================
RCS file: testsuite/gcc.dg/pr18501.c
diff -N testsuite/gcc.dg/pr18501.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/pr18501.c 17 Dec 2004 22:14:45 -0000
@@ -0,0 +1,20 @@
+/* Expected uninitialized variable warning. */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+unsigned bmp_iter_set ();
+int something (void);
+
+void
+bitmap_print_value_set (void)
+{
+ unsigned first; /* { dg-warning "may be used" "conditional in loop" } */
+
+ for (; bmp_iter_set (); )
+ {
+ if (!first)
+ something ();
+ first = 0;
+ }
+}
Index: testsuite/gcc.dg/uninit-5.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/uninit-5.c,v
retrieving revision 1.3
diff -d -c -p -u -r1.3 uninit-5.c
--- testsuite/gcc.dg/uninit-5.c 13 May 2004 06:40:49 -0000 1.3
+++ testsuite/gcc.dg/uninit-5.c 17 Dec 2004 22:14:45 -0000
@@ -9,7 +9,7 @@ extern void foo(void);
void
func1(int cond)
{
- int x; /* { dg-bogus "x" "uninitialized variable warning" } */
+ int x; /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */
if(cond)
x = 1;
@@ -23,7 +23,7 @@ func1(int cond)
void
func2 (int cond)
{
- int x; /* { dg-bogus "x" "uninitialized variable warning" } */
+ int x; /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */
int flag = 0;
if(cond)
Index: testsuite/gcc.dg/uninit-9.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/uninit-9.c,v
retrieving revision 1.3
diff -d -c -p -u -r1.3 uninit-9.c
--- testsuite/gcc.dg/uninit-9.c 13 May 2004 06:40:49 -0000 1.3
+++ testsuite/gcc.dg/uninit-9.c 17 Dec 2004 22:14:45 -0000
@@ -23,7 +23,7 @@ func(struct foo *list, int count)
{
int n_clobbers = 0;
int i;
- struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" } */
+ struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" { xfail *-*-* } } */
if(list[0].type == PARALLEL)
{