From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5947A3858D35; Tue, 4 Jul 2023 13:36:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5947A3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688477817; bh=WplBUkGk6GjeSyUHtxCfzpq46wcI/FDN/XERcQ8f568=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KMru6V0tGYSbGzHXOfq9XoUAw7fKxiEtI4s7RjeW76nOrHX7oe0q0xqYbTlkU3AxQ Dl4EWs1ZvHsLFvGO3s+SMc0A0+ltBLJ75+YTxZBE0E7NomWdZyhDNLhYdIidqRmN0+ OMuyxWrGoVMlJaXui8/CrV+9NLyHQBSRcWpTdLSo= From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110228] [13/14 Regression] llvm-16 miscompiled due to an maybe uninitialized variable Date: Tue, 04 Jul 2023 13:36:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox 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: 13.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D110228 --- Comment #32 from Sergei Trofimovich --- (In reply to Richard Biener from comment #29) > I can't reproduce the original failure on trunk or with GCC 13.1, but the > testcase from comment#16 is now fixed. I also cannot reproduce the testc= ase > from comment#21 before the fix. >=20 > Can people double-check this is now fixed, maybe also on the branch when = this > fix is cherry-picked? Test suite on llvm-16 still fails the same single 'LLVM :: ExecutionEngine/JITLink/X86/MachO_weak_references.s' test for me.=20 gcc was built from 2c12ccf800fc7890925402d30a02f0fa9e2627cc. The following test still fails for me: $ cat bug.c static unsigned a[4] =3D {1,1,1,1}; __attribute__((noipa)) static void bug(unsigned * p, unsigned *t, int n) { unsigned LookupFlags; for(int i =3D 0; i < n; i++) { unsigned v =3D t[i]; if (v =3D=3D 0) LookupFlags =3D 0; else if (v =3D=3D 1) LookupFlags =3D 1; *p =3D LookupFlags; } } int main() { unsigned r =3D 42; bug(&r, a, 4); if (r !=3D 1) __builtin_abort(); return 0; } $ gcc bug.c -o bug -O1 -Wall && ./bug bug.c: In function 'bug': bug.c:10:15: warning: 'LookupFlags' may be used uninitialized [-Wmaybe-uninitialized] 10 | else if (v =3D=3D 1) LookupFlags =3D 1; | ^ bug.c:5:15: note: 'LookupFlags' was declared here 5 | unsigned LookupFlags; | ^~~~~~~~~~~ Aborted (core dumped) bug.c.255t.optimized still turns stores into '|=3D' against uninit value: __attribute__((noipa, noinline, noclone, no_icf)) void bug (unsigned int * p, unsigned int * t, int n) { unsigned long ivtmp.8; unsigned int v; unsigned int LookupFlags; _Bool _16; unsigned int _17; unsigned int _18; void * _19; unsigned long _20; unsigned long _26; unsigned long _28; [local count: 118111600]: if (n_10(D) > 0) goto ; [89.00%] else goto ; [11.00%] [local count: 105119324]: ivtmp.8_21 =3D (unsigned long) t_11(D); _20 =3D (unsigned long) n_10(D); _26 =3D _20 * 4; _28 =3D ivtmp.8_21 + _26; [local count: 955630225]: # LookupFlags_22 =3D PHI # ivtmp.8_6 =3D PHI _19 =3D (void *) ivtmp.8_6; v_12 =3D MEM[(unsigned int *)_19]; if (v_12 =3D=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 477815112]: _16 =3D v_12 =3D=3D 1; _17 =3D (unsigned int) _16; _18 =3D _17 | LookupFlags_22; [local count: 955630225]: # LookupFlags_4 =3D PHI *p_13(D) =3D LookupFlags_4; ivtmp.8_5 =3D ivtmp.8_6 + 4; if (ivtmp.8_5 !=3D _28) goto ; [89.00%] else goto ; [11.00%] [local count: 118111600]: return; }=