public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "notasas at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/67037] New: [4.9 Regression] Wrong code at -O1 and above on ARM
Date: Mon, 27 Jul 2015 22:24:00 -0000	[thread overview]
Message-ID: <bug-67037-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 67037
           Summary: [4.9 Regression] Wrong code at -O1 and above on ARM
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: notasas at gmail dot com
  Target Milestone: ---
            Target: arm-unknown-linux-gnueabi, arm-linux-gnueabihf

Created attachment 36076
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36076&action=edit
testcase

The reduced testcase (based on "real" code from wine sources) crashes:

notaz@evm:/tmp/t$ cc -Wall -O0 testcase.c && ./a.out
notaz@evm:/tmp/t$ cc -Wall -O1 testcase.c && ./a.out
Segmentation fault
notaz@evm:/tmp/t$ cc -Wall -O2 testcase.c && ./a.out
Segmentation fault
notaz@evm:/tmp/t$ cc -Wall -Os testcase.c && ./a.out
notaz@evm:/tmp/t$ cc -Wall -O1 testcase.c -mcpu=arm920t -marm && ./a.out
Segmentation fault
notaz@evm:/tmp/t$ cc -Wall -O1 testcase.c -mcpu=cortex-a15 && ./a.out
Segmentation fault

gcc 4.7.2 and 4.8.2 seem to be ok.

It looks like this chunk

    while ((count > 1) && *s)
    {
        count--;
        *d++ = *s++;
    }

is compiled to

        add     r3, sp, #5312
        add     r3, r3, #52
        ldr     r3, [r3]        @ count
        cmp     r3, #1
        bls     .L6
        movw    r2, #:lower16:.LANCHOR0
        mov     r3, #78
        movt    r2, #:upper16:.LANCHOR0
        b       .L8
.L18:
        ldrh    r3, [r2, #2]!
        cmp     r3, #0
        beq     .L9
.L8:
        add     r1, sp, #5312
        add     r1, r1, #52
        ldr     r0, [r1]
        sub     r0, r0, #1
        str     r0, [r1]
        ldr     r1, [r3]        @ <-- crash
        cmp     r0, #1
        strh    r3, [r1], #2    @ movhi
        add     r3, sp, #5312
        add     r3, r3, #48
        str     r1, [r3]
        bne     .L18
.L9:

so it thinks r3 contains pointer to count, even though it loaded *s there?
The conditions for this bug seem to be large stack frame that load/store
offsets can't reach and enough register pressure.


             reply	other threads:[~2015-07-27 22:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 22:24 notasas at gmail dot com [this message]
2015-07-28  8:03 ` [Bug target/67037] " rguenth at gcc dot gnu.org
2015-07-28  9:03 ` mikpelinux at gmail dot com
2015-07-28  9:16 ` ktkachov at gcc dot gnu.org
2015-09-29 11:39 ` [Bug target/67037] [4.9/5/6 " bernd.edlinger at hotmail dot de
2015-09-29 12:23 ` [Bug rtl-optimization/67037] " edlinger at gcc dot gnu.org
2015-09-30 18:52 ` edlinger at gcc dot gnu.org
2015-10-19 23:00 ` [Bug rtl-optimization/67037] [4.9/5 " notasas at gmail dot com

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