public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/10842: [arm] Clobbered link register is copied to pc under certain circumstances
@ 2003-05-18  6:26 zhenya
  0 siblings, 0 replies; only message in thread
From: zhenya @ 2003-05-18  6:26 UTC (permalink / raw)
  To: gcc-gnats


>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==


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-18  6:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-18  6:26 optimization/10842: [arm] Clobbered link register is copied to pc under certain circumstances zhenya

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