From patchwork Thu Jun 9 18:44:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 99792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 10E34B6F90 for ; Fri, 10 Jun 2011 04:52:41 +1000 (EST) Received: (qmail 5715 invoked by alias); 9 Jun 2011 18:52:40 -0000 Received: (qmail 5702 invoked by uid 22791); 9 Jun 2011 18:52:39 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.160) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jun 2011 18:52:24 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by post.strato.de (jimi mo57) (RZmta 25.18) with ESMTPA id w01e38n59IE3Vy ; Thu, 9 Jun 2011 20:44:47 +0200 (MEST) Message-ID: <4DF1149C.3000604@gjlay.de> Date: Thu, 09 Jun 2011 20:44:44 +0200 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: "Eric B. Weddington" , Anatoly Sokolov , Denis Chertykov Subject: [Patch, AVR]: Fix thinko in avr_function_arg_advance X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch fixes a thinko in avr_function_arg_advance. Without the patch, following code will report false positive for passing args in fixed regs like: error: Register r0 is needed to pass a parameter but is fixed error: Register r1 is needed to pass a parameter but is fixed This is the code: typedef struct { char c[18]; } S; typedef struct { char c[26]; } T; char foo (S b, T a) { return b.c[9]; } The patch also uses same constraint for cfun->machine->sibcall_fails (even though it would not hut to have false positived there). Johann --- * config/avr/avr.c (avr_function_arg_advance): Fix thinko about when a value is actually passed in regs. Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (Revision 174701) +++ config/avr/avr.c (Arbeitskopie) @@ -1784,7 +1784,8 @@ avr_function_arg_advance (CUMULATIVE_ARG a function must not pass arguments in call-saved regs in order to get tail-called. */ - if (cum->regno >= 0 + if (cum->regno >= 8 + && cum->nregs >= 0 && !call_used_regs[cum->regno]) { /* FIXME: We ship info on failing tail-call in struct machine_function. @@ -1800,7 +1801,8 @@ avr_function_arg_advance (CUMULATIVE_ARG user has fixed a GPR needed to pass an argument, an (implicit) function call would clobber that fixed register. See PR45099 for an example. */ - if (cum->regno >= 0) + if (cum->regno >= 8 + && cum->nregs >= 0) { int regno;