From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 018E63857C7A; Tue, 22 Jun 2021 00:11:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 018E63857C7A From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101150] null pointer dereference false positive disappears when compiling an additional function Date: Tue, 22 Jun 2021 00:11:53 +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: 11.1.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed target_milestone bug_status keywords component cf_reconfirmed_on 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 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: Tue, 22 Jun 2021 00:11:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101150 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Target Milestone|--- |11.2 Status|UNCONFIRMED |NEW Keywords| |missed-optimization Component|c++ |tree-optimization Last reconfirmed| |2021-06-22 --- Comment #1 from Andrew Pinski --- There seems to be some missing optimizations (jump threading) here. First one: long int _12; _12 =3D _9 - _15; if (_12 !=3D 0) goto ; [33.00%] else goto ; [67.00%] // this should just jump to bb 15 because _12 =3D= =3D 0 and there for _9 =3D=3D _15 [local count: 79134772]: if (_9 !=3D _15) /// This should always be false coming from bb 2 because= _12 =3D=3D 0 there for _9 =3D=3D _15 goto ; [89.00%] else goto ; [11.00%] ... [local count: 104641928]: # _143 =3D PHI <_18(8), _9(3)> # _118 =3D PHI <_19(8), _15(3)> # v$_M_start_84 =3D PHI <_104(8), 0B(3)> # prephitmp_123 =3D PHI <_12(8), _12(3)> _133 =3D (unsigned long) _143; _110 =3D (unsigned long) _118; _125 =3D _133 - _110; .... [local count: 117575200]: return; Second one: ... [local count: 19488414]: _64 =3D (long unsigned int) _12; if (_64 > 9223372036854775804) goto ; [0.04%] else goto ; [99.96%] .... [local count: 9740309]: if (_12 !=3D 0) // This should always be true as _12 should always !=3D 0= on coming into this bb because we can only come via the if statement in bb 4 on the true edge of the conditional. goto ; [100.00%] else goto ; [0.00%] /// NOTE BB 16 is where the null pointer write it located --------- CUT ------- The reason why if you have both foo and bar defined, there is a heuristics = of the inlining of vector::_M_default_append which causes the difference, noth= ing shocking really.=