From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE64538AA24B; Mon, 5 Dec 2022 15:00:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE64538AA24B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670252443; bh=Dt3NhjA1sJ5U3b0PhtykeM8UVqvf2fI9lwEA4kuHX6U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=INaFH1yEZ+TdoHGQ++CJ9dJYJ4YCkU/XiBWcEtZM+HNp0/7yTigYt7kWxObAoJS6g u/45WL5Nud/iapT78SITEbaDwoGZDAWX8TM9oFLuvumAT5TdEHWg+GpB0Woc+IZi7n 69M/9h+wsWJYzaZPBV+Js5sHs+Dma0eb8j27COzM= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/40635] [12/13 Regression] bogus name and location in 'may be used uninitialized' warning Date: Mon, 05 Dec 2022 15:00:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.4.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status assigned_to Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D40635 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org --- Comment #26 from Richard Biener --- (In reply to Jeffrey A. Law from comment #25) > So current status is if you add -fno-inline, you can see the proper > uninitialized warning in get_tcp_socket, but we only get the declaration > site of s42, not the use site. So still broken, just in a different way > then the original report. I think for this issue we have duplicates - the use is on the GIMPLE_RETURN but those do not have locations (since we forcefully merge them), instead a PHI merge arg should but that doesn't have a location either in this case which is where we are lost. We start with [t.c:29:12] D.2772 =3D s42; [t.c:29:12] return D.2772; lowered to [t.c:29:12] D.2772 =3D s42; [t.c:29:12] goto ; : return D.2772; and with a CFG : [t.c:29:12] D.2772 =3D s42; : return D.2772; SSA: : # _8 =3D PHI <[t.c:21:20] _25(4), [t.c:28:16] _27(9), [t.c:29:12] _26(10)> return _8; thread1 causes the arg to split and lose locations: @@ -47,18 +82,23 @@ [t.c:18:34 discrim 1] if (_2 !=3D 0B) goto ; [96.34%] else - goto ; [3.66%] + goto ; [3.66%] - [local count: 75773864]: - # s42_4 =3D PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6), s42_17(D)= (2)> - # x_6 =3D PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6), [t.c:17:7] 0(2)> + [local count: 4159022]: + # s42_9 =3D PHI + # x_7 =3D PHI <[t.c:17:7] 0(2)> + goto ; [100.00%] + + [local count: 71614842]: + # s42_4 =3D PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6)> + # x_6 =3D PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6)> [t.c:27:8] if (x_6 < 0) - goto ; [0.73%] + goto ; [0.78%] else - goto ; [99.27%] + goto ; [99.22%] - [local count: 113634474]: - # _8 =3D PHI <[t.c:21:20] -1(4), [t.c:29:12] s42_4(7), [t.c:21:20] -1(3)> + [local count: 113634474]: + # _8 =3D PHI <[t.c:21:20] -1(4), s42_4(8), [t.c:21:20] -1(3), s42_9(7)> return _8; and the location is stripped by SSA update replacing _4 with its reaching def _4 (sic!) but running into gimple *stmt =3D SSA_NAME_DEF_STMT (reaching_def); gphi *other_phi =3D dyn_cast (stmt); /* Single element PHI nodes behave like copies, so get t= he location from the phi argument. */ if (other_phi && gimple_phi_num_args (other_phi) =3D=3D 1) locus =3D gimple_phi_arg_location (other_phi, 0); else locus =3D gimple_location (stmt); using the location of the _4 def (a multi-arg PHI) which is (as usual) UNKNOWN_LOCATION. Fixing that fixes the location on the edge from 7 and avoids some work but then I wonder why we adjust the PHI arg location _at all_ here (arguably we might want to replace UNKNOWN_LOCATION with a more meaningful location but not a meaningful location with UNKNOWN_LOCATION as we do here).=