public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI
@ 2022-06-12  1:32 josephcsible at gmail dot com
  2022-06-12 17:48 ` [Bug target/105932] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: josephcsible at gmail dot com @ 2022-06-12  1:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105932

            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 = x;
    rv.y = y;
    return rv;
}

When compiled with "-O2 -m32 -mabi=ms", 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 return
value. But in the i386 Microsoft ABI, that's not how returns work for POD types
that are 64 bits or smaller. Here's what it should compile to instead:

f:
        movd    x, %eax
        movd    y, %edx
        ret

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105932] Small structures returned incorrectly in i386 Microsoft ABI
  2022-06-12  1:32 [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI josephcsible at gmail dot com
@ 2022-06-12 17:48 ` pinskia at gcc dot gnu.org
  2022-06-14  7:58 ` rguenth at gcc dot gnu.org
  2022-09-18 21:15 ` green at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-12 17:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105932

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=81943

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this is a dup of bug 81943.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105932] Small structures returned incorrectly in i386 Microsoft ABI
  2022-06-12  1:32 [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI josephcsible at gmail dot com
  2022-06-12 17:48 ` [Bug target/105932] " pinskia at gcc dot gnu.org
@ 2022-06-14  7:58 ` rguenth at gcc dot gnu.org
  2022-09-18 21:15 ` green at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-14  7:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105932

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> I suspect this is a dup of bug 81943.

That's for a 64bit target though.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105932] Small structures returned incorrectly in i386 Microsoft ABI
  2022-06-12  1:32 [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI josephcsible at gmail dot com
  2022-06-12 17:48 ` [Bug target/105932] " pinskia at gcc dot gnu.org
  2022-06-14  7:58 ` rguenth at gcc dot gnu.org
@ 2022-09-18 21:15 ` green at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: green at redhat dot com @ 2022-09-18 21:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105932

Anthony Green <green at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |green at redhat dot com

--- Comment #3 from Anthony Green <green at redhat dot com> ---
I can confirm this bug.  I've been tearing my hair out all day over a series of
libffi test case failures on 32-bit x86.  Small structures aren't returned
properly for the MS ABI.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-18 21:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12  1:32 [Bug target/105932] New: Small structures returned incorrectly in i386 Microsoft ABI josephcsible at gmail dot com
2022-06-12 17:48 ` [Bug target/105932] " pinskia at gcc dot gnu.org
2022-06-14  7:58 ` rguenth at gcc dot gnu.org
2022-09-18 21:15 ` green at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).