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

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).