summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-07 10:30:13 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-07 10:30:13 +0000
commit182debc19bf676d2cf6d1e0ea0aec6016547943e (patch)
treeb789b0d2ed02e9f931f1b8d03fbcad41dcafc667
parent03404fe6f86b46fd9b14ee9f6a050051b889b217 (diff)
downloadgcc-182debc19bf676d2cf6d1e0ea0aec6016547943e.tar.gz
PR tree-optimization/57149
* tree-ssa-uninit.c (uninit_undefined_value_p): New inline. (can_skip_redundant_opnd, compute_uninit_opnds_pos, collect_phi_def_edges, execute_late_warn_uninitialized): Use uninit_undefined_value_p instead of ssa_undefined_value_p. * gcc.dg/pr57149.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198671 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr57149.c50
-rw-r--r--gcc/tree-ssa-uninit.c21
4 files changed, 76 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 853ca0aa77e..00a5502cbd2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2013-05-07 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/57149
+ * tree-ssa-uninit.c (uninit_undefined_value_p): New inline.
+ (can_skip_redundant_opnd, compute_uninit_opnds_pos,
+ collect_phi_def_edges, execute_late_warn_uninitialized): Use
+ uninit_undefined_value_p instead of ssa_undefined_value_p.
+
PR debug/57184
* expr.c (expand_expr_addr_expr_1): Handle COMPOUND_LITERAL_EXPR
for modifier == EXPAND_INITIALIZER.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dee99f81e9f..23e900ca13c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2013-05-07 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/57149
+ * gcc.dg/pr57149.c: New test.
+
PR debug/57184
* gcc.dg/pr57184.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr57149.c b/gcc/testsuite/gcc.dg/pr57149.c
new file mode 100644
index 00000000000..ab4d5e40899
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr57149.c
@@ -0,0 +1,50 @@
+/* PR tree-optimization/57149 */
+/* { dg-do compile } */
+/* { dg-options "-Os -Wuninitialized" } */
+
+struct A { struct A *a, *b; };
+struct D { struct A e; };
+struct E { unsigned char f; struct { struct A e; } g; };
+struct F { struct E i[32]; };
+
+extern int fn0 (void);
+extern int fn1 (struct E *, struct D *);
+
+static inline __attribute__ ((always_inline)) int
+fn2 (const struct A *x)
+{
+ return x->a == x;
+}
+
+static int
+fn3 (struct E *x)
+{
+ struct D *l, *m;
+ int retval = retval;
+ if (fn2 (&x->g.e))
+ return 0;
+ for (l = (struct D *) x->g.e.a, m = (struct D *) l->e.a;
+ &l->e != &x->g.e;
+ l = m, m = (struct D *) m->e.a)
+ retval = fn1 (x, l);
+ return retval;
+}
+
+void
+fn4 (struct F *x, unsigned k)
+{
+ unsigned i;
+ for (i = 0; i < k; i++)
+ {
+ struct E *y = &x->i[i];
+ int err = -22;
+ err = fn3 (y);
+ if (y->f == 0)
+ {
+ if (err > 0)
+ err = fn0 ();
+ if (err < 0) /* { dg-bogus "may be used uninitialized in this function" } */
+ fn0 ();
+ }
+ }
+}
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 2cb22b7035e..aa01c51658f 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -101,6 +101,19 @@ ssa_undefined_value_p (tree t)
&& pointer_set_contains (possibly_undefined_names, t)));
}
+/* Like ssa_undefined_value_p, but don't return true if TREE_NO_WARNING
+ is set on SSA_NAME_VAR. */
+
+static inline bool
+uninit_undefined_value_p (tree t)
+{
+ if (!ssa_undefined_value_p (t))
+ return false;
+ if (SSA_NAME_VAR (t) && TREE_NO_WARNING (SSA_NAME_VAR (t)))
+ return false;
+ return true;
+}
+
/* Checks if the operand OPND of PHI is defined by
another phi with one operand defined by this PHI,
but the rest operands are all defined. If yes,
@@ -124,7 +137,7 @@ can_skip_redundant_opnd (tree opnd, gimple phi)
tree op = gimple_phi_arg_def (op_def, i);
if (TREE_CODE (op) != SSA_NAME)
continue;
- if (op != phi_def && ssa_undefined_value_p (op))
+ if (op != phi_def && uninit_undefined_value_p (op))
return false;
}
@@ -149,7 +162,7 @@ compute_uninit_opnds_pos (gimple phi)
{
tree op = gimple_phi_arg_def (phi, i);
if (TREE_CODE (op) == SSA_NAME
- && ssa_undefined_value_p (op)
+ && uninit_undefined_value_p (op)
&& !can_skip_redundant_opnd (op, phi))
{
/* Ignore SSA_NAMEs on abnormal edges to setjmp
@@ -518,7 +531,7 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
gimple_bb (def), cd_root))
collect_phi_def_edges (def, cd_root, edges,
visited_phis);
- else if (!ssa_undefined_value_p (opnd))
+ else if (!uninit_undefined_value_p (opnd))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -2002,7 +2015,7 @@ execute_late_warn_uninitialized (void)
{
tree op = gimple_phi_arg_def (phi, i);
if (TREE_CODE (op) == SSA_NAME
- && ssa_undefined_value_p (op))
+ && uninit_undefined_value_p (op))
{
worklist.safe_push (phi);
pointer_set_insert (added_to_worklist, phi);