On Fri, 26 Apr 2013, Jakub Jelinek wrote:
> Hi!
>
> Bootstrap currently fails in libgo, there are false positive warnings
> that ({anonymous}) is uninitialized in multiple places.
>
> The testcase below reproduces this issue too. The problem is
> that the ab edges to setjmp call are added conservatively, thus they can be
> added even from calls before the setjmp call, that are never executed after
> the setjmp, and in their bb's some variables might not be initialized yet,
> even if their initialization dominates the setjmp call.
>
> As discussed on IRC, the following patch let us ignore the SSA_NAMEs on such
> abnormal edges. Perhaps later on we could try to do something for the
> common case where there is exactly one setjmp call or exactly one nonlocal
> goto label in a function, we could then avoid creating abnormal edges that
> aren't needed (calls that don't appear on any path from the single setjmp
> call to exit don't need to have ab edge to it). Bootstrapped/regtested on
> x86_64-linux and i686-linux (including go), ok for trunk?
Ok.
Thanks,
Richard.
> 2013-04-25 Jakub Jelinek <[email protected]>
>
> * tree-ssa-uninit.c (compute_uninit_opnds_pos): In functions
> with nonlocal goto receivers or returns twice calls, ignore
> unininitialized values from abnormal edges to nl goto receiver
> or returns twice call.
>
> * gcc.dg/setjmp-5.c: New test.
>
> --- gcc/tree-ssa-uninit.c.jj 2013-03-04 10:37:48.000000000 +0100
> +++ gcc/tree-ssa-uninit.c 2013-04-25 17:52:55.215166853 +0200
> @@ -151,7 +151,21 @@ compute_uninit_opnds_pos (gimple phi)
> if (TREE_CODE (op) == SSA_NAME
> && ssa_undefined_value_p (op)
> && !can_skip_redundant_opnd (op, phi))
> - MASK_SET_BIT (uninit_opnds, i);
> + {
> + /* Ignore SSA_NAMEs on abnormal edges to setjmp
> + or nonlocal goto receiver. */
> + if (cfun->has_nonlocal_label || cfun->calls_setjmp)
> + {
> + edge e = gimple_phi_arg_edge (phi, i);
> + if (e->flags & EDGE_ABNORMAL)
> + {
> + gimple last = last_stmt (e->src);
> + if (last && stmt_can_make_abnormal_goto (last))
> + continue;
> + }
> + }
> + MASK_SET_BIT (uninit_opnds, i);
> + }
> }
> return uninit_opnds;
> }
> --- gcc/testsuite/gcc.dg/setjmp-5.c.jj 2013-04-25 17:54:49.679559650
> +0200
> +++ gcc/testsuite/gcc.dg/setjmp-5.c 2013-04-25 17:55:08.084460447 +0200
> @@ -0,0 +1,22 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -Wall" } */
> +
> +#include <setjmp.h>
> +
> +void bar (int);
> +
> +jmp_buf buf;
> +int v;
> +
> +void
> +foo (void)
> +{
> + int i;
> + bar (0);
> + bar (1);
> + i = 5;
> + int j = setjmp (buf);
> + if (j == 0)
> + bar (2);
> + v = i; /* { dg-bogus "may be used uninitialized in this function" } */
> +}
>
> Jakub
>
>
--
Richard Biener <[email protected]>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend