From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3762 invoked by alias); 7 Mar 2013 12:47:09 -0000 Received: (qmail 3222 invoked by uid 48); 7 Mar 2013 12:46:37 -0000 From: "mh+gcc at glandium dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/56561] New: Miscompilation with -Os -arm Date: Thu, 07 Mar 2013 12:47: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: mh+gcc at glandium dot org 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: 2013-03/txt/msg00587.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56561 Bug #: 56561 Summary: Miscompilation with -Os -arm Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: mh+gcc@glandium.org Created attachment 29609 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29609 Testcase (originally posted on http://gcc.gnu.org/ml/gcc/2013-03/msg00051.html) At Mozilla, we've encountered a GCC 4.6 miscompilation in the ARMv6 build of Firefox for Android. We'd like to evaluate whether this bug is hitting us in more places than the one we spotted. To that end, we'd need to know what particular bug in GCC leads to this miscompilation. The attached file is the preprocessed source, slightly simplified, and with enough additions to allow it to be self-contained and with a main() that is able to act on the miscompilation being there or not. I was able to reproduce the miscompilation with both the GCC 4.6 from the Android NDK r8d and 4.6.3 from Debian unstable. It apparently happens for any -march, with -marm, but not -mthumb. It happens at -Os but not -O2. The problematic assembly looks like the following. It corresponds to the C code after the second call to DER_SetUInteger in sftk_mkPrivKey:: bl DER_SetUInteger(PLT) mov r3, #0 cmp sl, r3 movne r0, #2 moveq r0, r3 sl/r10 is never set anywhere in the function, so we're getting random behaviour. This doesn't happen with GCC 4.7, which suggests it may be a known bug. Any ideas? (On an ARM host:) $ gcc -o pkcs11 pkcs11.i -marm -Os -fno-inline ./pkcs11 $ ./pkcs11 FAIL $ gcc -o pkcs11 pkcs11.i -marm -O2 -fno-inline ./pkcs11 $ ./pkcs11 PASS