From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D58473858C27; Sun, 21 Mar 2021 15:34:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D58473858C27 From: "rth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99696] New: lto looks past aliases to initializers Date: Sun, 21 Mar 2021 15:34:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rth 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 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: Sun, 21 Mar 2021 15:34:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99696 Bug ID: 99696 Summary: lto looks past aliases to initializers Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: rth at gcc dot gnu.org Target Milestone: --- The following is a c-ish version of const int y =3D init(); which no longer works with gcc 11. The intended advantage to the program from which this is extracted is that references to Y may be cse'd across calls. IMO this should work fine with LTO, so long as it does not apply the constant initializer optimization to const variables that are aliased. Compile: gcc -O2 -flto y?.c --- y1.c --- #include extern const int y; int main(void) { assert(y =3D=3D 1); return 0; } --- y2.c --- static int x; extern const int y __attribute__((alias("x"))); static void __attribute__((constructor)) init(void) { x =3D 1; }=