From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1827 invoked by alias); 18 May 2003 06:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 1806 invoked by uid 71); 18 May 2003 06:26:00 -0000 Resent-Date: 18 May 2003 06:26:00 -0000 Resent-Message-ID: <20030518062600.1805.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, zhenya@silverbrookresearch.com Received: (qmail 27454 invoked by uid 48); 18 May 2003 06:22:32 -0000 Message-Id: <20030518062232.27453.qmail@sources.redhat.com> Date: Sun, 18 May 2003 06:26:00 -0000 From: zhenya@silverbrookresearch.com Reply-To: zhenya@silverbrookresearch.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/10842: [arm] Clobbered link register is copied to pc under certain circumstances X-SW-Source: 2003-05/txt/msg02015.txt.bz2 List-Id: >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==