public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102631] -Wmaybe-uninitialized cannot see through a series of PHIs
Date: Wed, 06 Oct 2021 16:51:12 +0000 [thread overview]
Message-ID: <bug-102631-4-5gXLYX0RiK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102631-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102631
--- Comment #3 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Aldy Hernandez from comment #2)
> Created attachment 51562 [details]
> similar problem on aarch64 bootstrap
$ ./cc1plus calls-aarch64.ii -O2 -quiet -Wall
In function ‘void mark_stack_region_used(poly_uint64, poly_uint64)’,
inlined from ‘rtx_def* emit_library_call_value_1(int, rtx, rtx,
libcall_type, machine_mode, int, rtx_mode_t*)’ at
/home/aldyh/src/gcc/gcc/calls.c:4536:29:
/home/aldyh/src/gcc/gcc/calls.c:206:26: warning: ‘const_upper’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
206 | stack_usage_map[i] = 1;
| ~~~~~~~~~~~~~~~~~~~^~~
/home/aldyh/src/gcc/gcc/calls.c: In function ‘rtx_def*
emit_library_call_value_1(int, rtx, rtx, libcall_type, machine_mode, int,
rtx_mode_t*)’:
/home/aldyh/src/gcc/gcc/calls.c:202:30: note: ‘const_upper’ was declared here
202 | unsigned HOST_WIDE_INT const_lower, const_upper;
| ^~~~~~~~~~~
As I've described here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581045.html
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.
This looks very similar.
The source is here, which is obviously properly guarded:
static void
mark_stack_region_used (poly_uint64 lower_bound, poly_uint64 upper_bound)
{
unsigned HOST_WIDE_INT const_lower, const_upper;
const_lower = constant_lower_bound (lower_bound);
if (upper_bound.is_constant (&const_upper))
for (unsigned HOST_WIDE_INT i = const_lower; i < const_upper; ++i)
stack_usage_map[i] = 1;
else
stack_usage_watermark = MIN (stack_usage_watermark, const_lower);
}
next prev parent reply other threads:[~2021-10-06 16:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 16:43 [Bug tree-optimization/102631] New: " aldyh at gcc dot gnu.org
2021-10-06 16:44 ` [Bug tree-optimization/102631] " aldyh at gcc dot gnu.org
2021-10-06 16:47 ` aldyh at gcc dot gnu.org
2021-10-06 16:51 ` aldyh at gcc dot gnu.org [this message]
2021-10-07 8:21 ` aldyh at gcc dot gnu.org
2022-08-31 14:17 ` rguenth at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-102631-4-5gXLYX0RiK@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).