From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 737B83857C44; Fri, 11 Nov 2022 16:05:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 737B83857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668182702; bh=F79M0DhHFmDLxNTatXJgAPCFDQCC/8Yi7WhcomLasvE=; h=From:To:Subject:Date:From; b=w42GJFNnqZCVNR5xgameR3HHd4oMnUIzfo+A4QUoMCZt9//bg+uyDESNKUorqiD5F D3t5t6xmARYIguxEXFrcaeOrCLTNKYetwHHRnk0GI7FRsAU2e8/o309bZLh2jMDbb3 U55uyoUVw0Wpgi6wGkT7Jme+5hEQgGHa/UGVfQjU= From: "jamborm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/107640] New: IPA-CP drops known values passed by reference when the reference is to a global variable Date: Fri, 11 Nov 2022 16:05:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jamborm 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 keywords bug_severity priority component assigned_to reporter cc target_milestone cf_gcchost cf_gcctarget 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107640 Bug ID: 107640 Summary: IPA-CP drops known values passed by reference when the reference is to a global variable Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: jamborm at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- Host: x86_64-linux Target: x86_64-linux Combining IPA-CP of (scalar) parameter values and of values passed by refer= ence (aggregate values) does not work in the same function parameter, we drop the aggregate values on the floor. The following aborts when compiled with -O2 -DFAIL struct S { int a, b, c; }; volatile int gi; void __attribute__((noipa)) consume_s (struct S *p) { gi =3D p->a; } static void __attribute__((noinline)) foo (struct S *p) { if (!__builtin_constant_p (p->b)) __builtin_abort (); consume_s (p); } static struct S __attribute((used)) gs; int main (int argc, char *argv[]) { struct S *p; #ifdef FAIL p =3D &gs; #else struct S s; p =3D &s; #endif p->a =3D 10; p->b =3D 20; foo (p); return 0; }=