[Andrew, ranger comment embedded below.]
On 10/7/21 1:06 AM, Jeff Law wrote:
On 10/6/2021 7:47 AM, Aldy Hernandez via Gcc-patches wrote:
The pending patch I have from Richi fixes this. Even so, it's the
uninit code that's confused.
Sigh...every single change to the threading code shines the light on
some warning bug.
If you take the calls.ii file from the aarch64 bootstrap and break on
the warning, you can see that the uninitalized use is for
const_upper_3934 here:
<bb 102> [local count: 315357954]:
# const_upper_3934 = PHI <const_upper_3937(D)(101), _6707(293)>
if (_881 != 0)
goto <bb 103>; [50.00%]
else
goto <bb 106>; [50.00%]
<bb 103> [local count: 157678977]:
if (const_upper_3934 > _6699)
goto <bb 105>; [89.00%]
else
goto <bb 294>; [11.00%]
<bb 294> [local count: 17344687]:
<bb 104> [local count: 157678977]:
goto <bb 107>; [100.00%]
<bb 105> [local count: 140334290]:
stack_usage_map.481_3930 = stack_usage_map;
_6441 = const_upper_3934 - _6699;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PROBLEMATIC READ HERE
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_4819 = stack_usage_map.481_3930 + _6699;
__builtin_memset (_4819, 1, _6441);
goto <bb 104>; [11.00%]
const_upper_3934 could be undefined if it comes from BB101
(const_upper_3937(D)), but it only gets read for _881 != 0, so it
shouldn't warn.
I suggest -Wmaybe-uninitialized be turned off for that file until the
warning is fixed.
And yes, the proposed patch will also cure this, but the underlying
problem in the warning is still there.
You haven't shown enough context for me to agree or disagree. Are there
other preds to bb105? I hate these slimmed down dumps. I work better
with the full pred/succ lists. -fdump-tree-<whatever>-blocks-details :-)
It appears to me that for _881 != 0 we certainly flow into the read of
_const_upper_3934 in bb103 and bb105. Why do you think that's safe?
My bad, there's some missing context.
The only way to get to BB101->BB102 is through:
<bb 100>
if (_6711 != 0)
goto <bb 101>; [5.50%]
else
goto <bb 293>; [94.50%]
And there's an implicit relation between _6711 and _811:
<bb 86>
...
if (_6711 != 0)
goto <bb 287>; [5.50%]
else
goto <bb 87>; [94.50%]
<bb 287> [local count: 17344687]:
goto <bb 88>; [100.00%]
<bb 87> [local count: 298013267]:
<bb 88> [local count: 315357954]:
# _881 = PHI <1(87), 0(287)>
That is, _6711 == !_881.
[Andrew, it'd be neat if we could teach ranger the relationship between
_6711 and _811 above. And also, that _881 is [0,1]. Perhaps with the
relation oracle, the uninit code could notice that a _6711 guard is also
a !_811 guard.]
Presumably the threader shuffled things sufficiently so that the above
relationship was difficult to devise.
Your preferred full context follows ;-).
Aldy
----
Here we see that _881 == 0 when _6711 != 0:
;; basic block 286, loop depth 1, count 640272214 (estimated locally),
maybe hot
;; prev block 85, next block 86, flags: (NEW)
;; pred: 85 [67.0% (guessed)] count:640272214 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
goto <bb 112>; [100.00%]
;; succ: 112 [always] count:640272214 (estimated locally)
(FALLTHRU)
;; basic block 86, loop depth 1, count 315357954 (estimated locally),
maybe hot
;; prev block 286, next block 287, flags: (NEW, REACHABLE, VISITED)
;; pred: 85 [33.0% (guessed)] count:315357953 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
_4293 = MEM[(long int *)_5338 + 80B];
_6727 = MEM[(long int *)_5338 + 88B];
_6715 = MEM[(long int *)_5338 + 32B];
_4305 = _4293 + _6715;
_4299 = MEM[(long int *)_5338 + 40B];
_4300 = _4299 + _6727;
_6707 = (long unsigned int) _4305;
_6711 = (long unsigned int) _4300;
_6699 = (long unsigned int) _4293;
if (_6711 != 0)
goto <bb 287>; [5.50%]
else
goto <bb 87>; [94.50%]
;; succ: 287 [5.5% (guessed)] count:17344687 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 87 [94.5% (guessed)] count:298013267 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 287, loop depth 1, count 17344687 (estimated locally),
maybe hot
;; prev block 86, next block 87, flags: (NEW)
;; pred: 86 [5.5% (guessed)] count:17344687 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
goto <bb 88>; [100.00%]
;; succ: 88 [always] count:17344687 (estimated locally) (FALLTHRU)
;; basic block 87, loop depth 1, count 298013267 (estimated locally),
maybe hot
;; prev block 287, next block 88, flags: (NEW, VISITED)
;; pred: 86 [94.5% (guessed)] count:298013267 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; succ: 88 [always] count:298013267 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; basic block 88, loop depth 1, count 315357954 (estimated locally),
maybe hot
;; prev block 87, next block 89, flags: (NEW, REACHABLE, VISITED)
;; pred: 87 [always] count:298013267 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; 287 [always] count:17344687 (estimated locally)
(FALLTHRU)
# const_upper_3863 = PHI <_6707(87), 18446744073709551615(287)>
# _881 = PHI <1(87), 0(287)>
[snip]
[snip]
[snip]
And here we see that the "undefined" read is guarded by _6711:
;; basic block 100, loop depth 1, count 315357955 (estimated locally),
maybe hot
;; prev block 99, next block 293, flags: (NEW, REACHABLE, VISITED)
;; pred: 98 [always] count:94607385 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; 99 [always] count:220750569 (estimated locally)
(FALLTHRU,EXECUTABLE)
# iftmp.581_254 = PHI <_669(98), _3922(99)>
MEM[(struct poly_int *)&D.150826] ={v} {CLOBBER};
_4417 = MEM[(long int *)_5338 + 56B];
MEM[(struct poly_int *)&D.150826].D.21135.coeffs[0] = _4417;
_4410 = MEM[(long int *)_5338 + 64B];
MEM[(struct poly_int *)&D.150826].D.21135.coeffs[1] = _4410;
_673 = gen_int_mode (D.150826, 16);
MEM[(struct poly_int *)&D.150832] ={v} {CLOBBER};
MEM[(struct poly_int *)&D.150832].D.21135.coeffs[0] = 0;
MEM[(struct poly_int *)&D.150832].D.21135.coeffs[1] = 0;
emit_push_insn (val_598, mode_597, 0B, 0B, parm_align_601,
partial_600, reg_599, D.150832, argblock_88, _673, 0, iftmp.581_254, 0);
D.150832 ={v} {CLOBBER};
D.150826 ={v} {CLOBBER};
D.150830 ={v} {CLOBBER};
D.150828 ={v} {CLOBBER};
if (_6711 != 0)
goto <bb 101>; [5.50%]
else
goto <bb 293>; [94.50%]
;; succ: 101 [5.5% (guessed)] count:17344687 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 293 [94.5% (guessed)] count:298013268 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 293, loop depth 1, count 298013268 (estimated locally),
maybe hot
;; prev block 100, next block 101, flags: (NEW)
;; pred: 100 [94.5% (guessed)] count:298013268 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
goto <bb 102>; [100.00%]
;; succ: 102 [always] count:298013268 (estimated locally)
(FALLTHRU)
;; basic block 101, loop depth 1, count 17344687 (estimated locally),
maybe hot
;; prev block 293, next block 102, flags: (NEW, VISITED)
;; pred: 100 [5.5% (guessed)] count:17344687 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; succ: 102 [always] count:17344687 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; basic block 102, loop depth 1, count 315357954 (estimated locally),
maybe hot
;; prev block 101, next block 103, flags: (NEW, REACHABLE, VISITED)
;; pred: 101 [always] count:17344687 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; 293 [always] count:298013268 (estimated locally)
(FALLTHRU)
# const_upper_3934 = PHI <const_upper_3937(D)(101), _6707(293)>
if (_881 != 0)
goto <bb 103>; [50.00%]
else
goto <bb 106>; [50.00%]
;; succ: 103 [50.0% (guessed)] count:157678977 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 106 [50.0% (guessed)] count:157678977 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 103, loop depth 1, count 157678977 (estimated locally),
maybe hot
;; prev block 102, next block 294, flags: (NEW, REACHABLE, VISITED)
;; pred: 102 [50.0% (guessed)] count:157678977 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
if (const_upper_3934 > _6699)
goto <bb 105>; [89.00%]
else
goto <bb 294>; [11.00%]
;; succ: 105 [89.0% (guessed)] count:140334290 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 294 [11.0% (guessed)] count:17344687 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 294, loop depth 1, count 17344687 (estimated locally),
maybe hot
;; prev block 103, next block 104, flags: (NEW)
;; pred: 103 [11.0% (guessed)] count:17344687 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; succ: 104 [always] count:17344687 (estimated locally)
(FALLTHRU)
;; basic block 104, loop depth 1, count 157678977 (estimated locally),
maybe hot
;; Invalid sum of incoming counts 32781459 (estimated locally), should
be 157678977 (estimated locally)
;; prev block 294, next block 105, flags: (NEW, VISITED)
;; pred: 294 [always] count:17344687 (estimated locally)
(FALLTHRU)
;; 105 [11.0% (guessed)] count:15436772 (estimated
locally) (FALLTHRU,EXECUTABLE)
goto <bb 107>; [100.00%]
;; succ: 107 [always] count:157678977 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; basic block 105, loop depth 1, count 140334290 (estimated locally),
maybe hot
;; prev block 104, next block 106, flags: (NEW, REACHABLE, VISITED)
;; pred: 103 [89.0% (guessed)] count:140334290 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
stack_usage_map.481_3930 = stack_usage_map;
_6441 = const_upper_3934 - _6699;
_4819 = stack_usage_map.481_3930 + _6699;
__builtin_memset (_4819, 1, _6441);
goto <bb 104>; [11.00%]