From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 27F133858415; Wed, 6 Oct 2021 16:43:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27F133858415 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102631] New: -Wmaybe-uninitialized cannot see through a series of PHIs Date: Wed, 06 Oct 2021 16:43:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 16:43:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102631 Bug ID: 102631 Summary: -Wmaybe-uninitialized cannot see through a series of PHIs Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: aldyh at gcc dot gnu.org Target Milestone: --- Created attachment 51561 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51561&action=3Dedit -Wmaybe-uninitialized false positive from libgomp with -O2 -Wall The read from start_data_870 is being flagged as uninitialized, but it is n= ot.=20 The uninitialized source (start_data_518(D)) only happens for _1 =3D=3D 0, = and that can't happen because the entire problematic read is predicated on _1 !=3D 0. Here is the read (notice it is predicated by _1 !=3D 0: EXHIBIT A: [count: 0]: _239 =3D gomp_tls_data.place; _593 =3D pthread_self (); gomp_display_affinity_thread (_593, &MEM [(void *)&gomp_tls_data + 16B], _239); if (_1 !=3D 0) goto ; [0.00%] else goto ; [0.00%] [count: 0]: goto ; [100.00%] [count: 0]: _240 =3D nthreads_414(D) + 4294967295; _241 =3D (long unsigned int) _240; _242 =3D _241 * 120; _1016 =3D 16 - _242; _341 =3D start_data_870 + _1016; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Wmaybe-uninitailized on the read from start_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ivtmp.98_342 =3D (unsigned long) _341; goto ; [0.00%] If we chase start_data_870, we see: EXHIBIT B: [local count: 33009259]: # start_data_781 =3D PHI # old_threads_used_887 =3D PHI # affinity_count_825 =3D PHI # affinity_thr_904 =3D PHI # force_display_840 =3D PHI _589 =3D &MEM[(struct gomp_simple_barrier_t *)pool_410 + 64B].bar; gomp_barrier_wait (_589); [local count: 66018519]: # start_data_870 =3D PHI # old_threads_used_908 =3D PHI # affinity_count_848 =3D PHI # affinity_thr_169 =3D PHI # force_display_830 =3D PHI start_data_870 could be uninitialized if it came from BB165 because it woul= d be start_data_781, which in turn could be start_data_518(D) from BB265. But notice, we still haven't read from start_data_870. As I have shown in the EXHIBIT A, the read from start_data_870 is predicated by _1 !=3D 0. Perhaps the uninit code is treating the series of PHIs as an uninitialized read: # start_data_781 =3D PHI ... ... # start_data_870 =3D PHI ... But AFAIK, the actual uninitialized read from start_data_870 wouldn't happen until we use it, and that only happens under proper predication: if (_1 !=3D 0) read from start_data_870=