public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: zhenya@silverbrookresearch.com
To: gcc-gnats@gcc.gnu.org
Subject: optimization/10842: [arm] Clobbered link register is copied to pc under certain circumstances
Date: Sun, 18 May 2003 06:26:00 -0000	[thread overview]
Message-ID: <20030518062232.27453.qmail@sources.redhat.com> (raw)


>Number:         10842
>Category:       optimization
>Synopsis:       [arm] Clobbered link register is copied to pc under certain circumstances
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun May 18 06:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Zhenya Yourlo
>Release:        gcc version 3.3
>Organization:
>Environment:
Host: FreeBSD 4.7-STABLE
Target: arm-elf
Configured with: ../configure --host=i386-unknown-freebsd4.7 --program-prefix=arm-elf- --target=arm-elf --disable-threads --with-cpu=arm7tdmi --enable-languages=c
>Description:
Compiling the attached code with -O3 -fno-inline-functions produces assembly that exhibits the following behaviour:

functionA branches with link to functionB.
functionB clobbers the link register and branches to functionC.
functionC returns with "mov pc, lr" but lr is no longer valid.

When compiling with -O2, the link register is not used as a scratch register in functionB, and hence the "mov pc, lr" used by functionC works as expected.

This appears to be a regression from 3.2.1 (has not been tested with 3.2.2).
>How-To-Repeat:
arm-elf-gcc -O3 -fno-inline-functions -save-temps -c gcc33bug.i
>Fix:
A workaround is to use -O2 in place of -O3, or use -ffixed-lr
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gcc33bug.i"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gcc33bug.i"

IyAxICJnY2MzM2J1Zy5jIgojIDEgIjxidWlsdC1pbj4iCiMgMSAiPGNvbW1hbmQgbGluZT4iCiMg
MSAiZ2NjMzNidWcuYyIKc3RydWN0IFJpbmcKewogICAgICAgIGludCBkdW1teTsKICAgICAgICBz
dHJ1Y3QgUmluZyAqbmV4dDsKfTsKCmludCBmdW5jdGlvbkEodm9pZCk7CgppbnQgZnVuY3Rpb25C
KGludCBkdW1teSwgc3RydWN0IFJpbmcgKnRoZVJpbmcsIHVuc2lnbmVkIGludCBudW1FbGVtcyk7
CgppbnQgZnVuY3Rpb25DKGludCBkdW1teSk7CgppbnQgZnVuY3Rpb25BCigKICAgICAgICB2b2lk
CikKewogICAgICAgIGludCBkdW1teTsKICAgICAgICBzdHJ1Y3QgUmluZyB0aGVSaW5nWzJdOwoK
ICAgICAgICBmdW5jdGlvbkIoZHVtbXksIHRoZVJpbmcsIDIpOwp9CgppbnQKZnVuY3Rpb25CCigK
ICAgICAgICBpbnQgZHVtbXksCiAgICAgICAgc3RydWN0IFJpbmcgKnRoZVJpbmcsCiAgICAgICAg
dW5zaWduZWQgaW50IG51bUVsZW1zCikKewogICAgICAgIHN0cnVjdCBSaW5nICpSaW5nUHRyOwog
ICAgICAgIGludCBpOwoKICAgICAgICBSaW5nUHRyID0gdGhlUmluZzsKICAgICAgICBmb3IgKGkg
PSBudW1FbGVtcyAtIDE7IGkgIT0gMDsgaS0tKQogICAgICAgIHsKICAgICAgICAgICAgICAgIFJp
bmdQdHItPm5leHQgPSBSaW5nUHRyICsgMTsKICAgICAgICAgICAgICAgIFJpbmdQdHIrKzsKICAg
ICAgICB9CiAgICAgICAgUmluZ1B0ci0+bmV4dCA9IHRoZVJpbmc7CgogICAgICAgIHJldHVybiBm
dW5jdGlvbkMoZHVtbXkpOwp9CgppbnQKZnVuY3Rpb25DCigKICAgICAgICBpbnQgZHVtbXkKKQp7
CiAgICAgICAgcmV0dXJuIGR1bW15Owp9Cg==


                 reply	other threads:[~2003-05-18  6:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030518062232.27453.qmail@sources.redhat.com \
    --to=zhenya@silverbrookresearch.com \
    --cc=gcc-gnats@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).