Hi,
I recently stumbled on the ??? comment in tree-ssa-uninit.c and wondered why
virtual operands are not enabled at -O0. As demonstrated by the attached
patch, this would make it possible to unXFAIL a few uninit-*.c testcases.
Tested on x86_64-suse-linux.
* tree-ssa-operands.c (create_vop_var): Set DECL_IGNORED_P.
(append_use): Run at -O0.
(append_vdef): Likewise.
* tree-ssa-uninit.c (warn_uninitialized_vars): Remove obsolete comment.
testsuite/
* gcc.dg/uninit-B-O0.c: Remove XFAIL.
* gcc.dg/uninit-I-O0.c: Likewise.
* gcc.dg/uninit-pr19430-O0.c: Remove some XFAILs.
--
Eric Botcazou
Index: tree-ssa-uninit.c
===================================================================
--- tree-ssa-uninit.c (revision 209411)
+++ tree-ssa-uninit.c (working copy)
@@ -210,7 +210,6 @@ warn_uninitialized_vars (bool warn_possi
/* For memory the only cheap thing we can do is see if we
have a use of the default def of the virtual operand.
- ??? Note that at -O0 we do not have virtual operands.
??? Not so cheap would be to use the alias oracle via
walk_aliased_vdefs, if we don't find any aliasing vdef
warn as is-used-uninitialized, if we don't find an aliasing
Index: testsuite/gcc.dg/uninit-I-O0.c
===================================================================
--- testsuite/gcc.dg/uninit-I-O0.c (revision 209411)
+++ testsuite/gcc.dg/uninit-I-O0.c (working copy)
@@ -3,6 +3,6 @@
int sys_msgctl (void)
{
- struct { int mode; } setbuf; /* { dg-warning "'setbuf\.mode' is used" {} { xfail *-*-* } } */
- return setbuf.mode;
+ struct { int mode; } setbuf;
+ return setbuf.mode; /* { dg-warning "'setbuf\.mode' is used uninitialized in this function" } */
}
Index: testsuite/gcc.dg/uninit-B-O0.c
===================================================================
--- testsuite/gcc.dg/uninit-B-O0.c (revision 209411)
+++ testsuite/gcc.dg/uninit-B-O0.c (working copy)
@@ -9,7 +9,7 @@ void
baz (void)
{
int i;
- if (i) /* { dg-warning "uninit" "uninit i warning" { xfail *-*-* } } */
+ if (i) /* { dg-warning "'i' is used uninitialized in this function" } */
bar (i);
foo (&i);
}
Index: testsuite/gcc.dg/uninit-pr19430-O0.c
===================================================================
--- testsuite/gcc.dg/uninit-pr19430-O0.c (revision 209411)
+++ testsuite/gcc.dg/uninit-pr19430-O0.c (working copy)
@@ -16,10 +16,9 @@ foo (int i)
return j;
}
-
int foo2( void ) {
- int rc; /* { dg-warning "'rc' is used uninitialized in this function" "uninitialized" { xfail *-*-* } 21 } */
- return rc;
+ int rc;
+ return rc; /* { dg-warning "'rc' is used uninitialized in this function" } */
*&rc = 0;
}
@@ -29,7 +28,7 @@ void frob(int *pi);
int main(void)
{
int i;
- printf("i = %d\n", i); /* { dg-warning "'i' is used uninitialized in this function" "uninitialized" { xfail *-*-* } 32 } */
+ printf("i = %d\n", i); /* { dg-warning "'i' is used uninitialized in this function" } */
frob(&i);
return 0;
@@ -38,6 +37,6 @@ int main(void)
void foo3(int*);
void bar3(void) {
int x;
- if(x) /* { dg-warning "'x' is used uninitialized in this function" "uninitialized" { xfail *-*-* } 41 } */
+ if(x) /* { dg-warning "'x' is used uninitialized in this function" } */
foo3(&x);
}
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c (revision 209411)
+++ tree-ssa-operands.c (working copy)
@@ -166,6 +166,7 @@ create_vop_var (struct function *fn)
get_identifier (".MEM"),
void_type_node);
DECL_ARTIFICIAL (global_var) = 1;
+ DECL_IGNORED_P (global_var) = 1;
TREE_READONLY (global_var) = 0;
DECL_EXTERNAL (global_var) = 1;
TREE_STATIC (global_var) = 1;
@@ -477,9 +478,6 @@ append_use (tree *use_p)
static inline void
append_vdef (tree var)
{
- if (!optimize)
- return;
-
gcc_assert ((build_vdef == NULL_TREE
|| build_vdef == var)
&& (build_vuse == NULL_TREE
@@ -495,9 +493,6 @@ append_vdef (tree var)
static inline void
append_vuse (tree var)
{
- if (!optimize)
- return;
-
gcc_assert (build_vuse == NULL_TREE
|| build_vuse == var);