From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10933 invoked by alias); 22 Mar 2012 15:45:40 -0000 Received: (qmail 10894 invoked by uid 22791); 22 Mar 2012 15:45:38 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Mar 2012 15:45:25 +0000 From: "dg at cowlark dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dg at cowlark dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg01935.txt.bz2 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).