From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11800 invoked by alias); 6 Dec 2010 09:08:02 -0000 Received: (qmail 11755 invoked by uid 22791); 6 Dec 2010 09:08:00 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Dec 2010 09:07:56 +0000 From: "mschulze at ivs dot cs.ovgu.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/45263] registers used in __do_global_ctors can get clobbered X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mschulze at ivs dot cs.ovgu.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 06 Dec 2010 09:08:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-12/txt/msg00532.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263 --- Comment #11 from Michael Schulze 2010-12-06 09:07:19 UTC --- (In reply to comment #9) > This is essentially identical to the patch I provided for > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44617 > so it looks good to me. I hadn't see that patch but you are right it's almost identical. > I had two worries: > Is R15 used anywhere else in startup code that might not obey the register > save conventions (ie does do_global_ctors need to preserve R15) > The AVR has a lot of opcodes that are not valid on registers less than 16. It > doesn't look like any of these are used here, but I wasn't 100% positive that > using R15 wouldn't cause problems... As far as I know r15 isn't used elsewhere in the start-up code and also your second worry seems not to be a problem, because such instructions are not used by that time. (In reply to comment #10) > I strongly suggest not using R15. The ATtiny10 Family of devices > (ATtiny10/4/5/9/20/40) only has R16-R31. So using R15 won't work for this > class of devices. I disagree because the additional register is only in the start up code of devices that have rampz and is omitted in all other cases. The ATtiny don't have a rampz (correct me if I'm wrong) thus they are not faced with the discussed problem in general. IMO, it is absolutely possible and correct to use r15 here. > It would be best if we can find a register that will for all AVR > devices. Due to the compiler's C calling conventions, there are no other free registers to use without the need of pushing and popping this registers. Only registers below r16 are free to use. All other free r16,r17,r28,r29 are already in use.