This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/10842: [arm] Clobbered link register is copied to pc under certain circumstances


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]