public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dg at cowlark dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/52670] New: -mabi=ms generates bad code
Date: Thu, 22 Mar 2012 15:52:00 -0000	[thread overview]
Message-ID: <bug-52670-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52670

             Bug #: 52670
           Summary: -mabi=ms generates bad code
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dg@cowlark.com


If I take this test case:

  int z(int i) { return i; }

...and compile it with:

  gcc-4.6 -Os -m32 -mabi=sysv -o test.s -c test.c -S -fomit-frame-pointer

...I get this (trimmed):

    movl    4(%esp), %eax
    ret

However, if I compile it with this:

  gcc-4.6 -Os -m32 -mabi=ms -o test.s -c test.c -S -fomit-frame-pointer

...then I get this, which is wrong:

    movl    36(%esp), %eax
    ret

Compiling with a copy of the Mingw compiler or with Visual C produces (the
equivalent of) the 4 result. The -fomit-frame-pointer is there purely to reduce
the size of the output; the bug persists without it. This appears to affect all
stack accesses. It *seems* to only apply to ia32 code. amd64 code appears to be
fine, but my target environment is ia32 only so I haven't looked into amd64
much.

This was discussed on gcc-help here:

  http://gcc.gnu.org/ml/gcc-help/2012-03/msg00281.html

This patch appears to fix the issue:

  http://gcc.gnu.org/ml/gcc-patches/2011-03/txt00118.txt

(although the patch needs a bit of work to apply).


             reply	other threads:[~2012-03-22 15:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 15:52 dg at cowlark dot com [this message]
2023-12-17  7:12 ` [Bug target/52670] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52670-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).