From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 810EC385C316; Sun, 12 Jun 2022 01:32:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 810EC385C316 From: "josephcsible at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI Date: Sun, 12 Jun 2022 01:32:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: josephcsible at gmail dot com 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 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, 12 Jun 2022 01:32:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105932 Bug ID: 105932 Summary: Small structures returned incorrectly in i386 Microsoft ABI Product: gcc Version: 12.1.0 Status: UNCONFIRMED Keywords: ABI, wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: josephcsible at gmail dot com Target Milestone: --- Consider this C code: struct foo { int x, y; }; extern int x, y; struct foo f(void) { struct foo rv; rv.x =3D x; rv.y =3D y; return rv; } When compiled with "-O2 -m32 -mabi=3Dms", it compiles to this: f: movd x, %xmm0 movl 4(%esp), %eax movd y, %xmm1 punpckldq %xmm1, %xmm0 movq %xmm0, (%eax) ret Which expects to be passed a hidden parameter to hold the address of the re= turn value. But in the i386 Microsoft ABI, that's not how returns work for POD t= ypes that are 64 bits or smaller. Here's what it should compile to instead: f: movd x, %eax movd y, %edx ret=