On 08/08/2016 08:43 PM, Andi Kleen wrote:
Ideally we'd have a test that we could more deeply analyze for paths
through the CFG that can't be executed. Finding those paths usually
both fixes the warning *and* results in better code. Even if we
can't fix it now, we can file it away for future work
It's multiple variables who are depending on each other, with complex
control flow inbetween. It's not surprising that it loses control
of all the combinations.
You can take a look yourself here:
/home/andi/gcc/git/gcc/gcc/tree-vrp.c: In function 'int
compare_values_warnv(tree, tree, bool*)':
/home/andi/gcc/git/gcc/gcc/tree-vrp.c:1251:12: error: 'inv2' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
tree inv = cst1 ? inv2 : inv1;
^~~
/home/andi/gcc/git/gcc/gcc/tree-vrp.c:1222:4: error: 'inv1' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
if (strict_overflow_p != NULL
~~~~~~~~~~~~~~~~~~~~~~~~~
&& (!inv1 || !TREE_NO_WARNING (val1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From my reading it looks to me like we could use inv2 uninitialized.
tree sym1 = get_single_symbol (val1, &neg1, &inv1);
tree sym2 = get_single_symbol (val2, &neg2, &inv2);
If sym1 results in a return value that is some useful tree and inv1 is
true and cst1 is true via this call:
const bool cst1 = is_gimple_min_invariant (val1);
We then need sym2 to result in a return value from get_single_symbol to
be NULL, but cst2 still be true via this statement:
const bool cst2 = is_gimple_min_invariant (val2);
If all those conditions can hold, then we'll use inv2 without
initializing it AFAICT.
The key here is can there be a value for val2 where val2 is an invariant
not built from PLUS_EXPR, POINTER_PLUS_EXPR, MINUS_EXPR or NEGATE_EXPR.
I think we can make that happen if val2 is an ADDR_EXPR with an
invariant address.
So it actually seems to me that unless ADDR_EXPR filtered out elsewhere
that we've got a real bug here rather than a false positive. There may
be others, that's just the first one that stood out.
Or did I miss something?
jeff