From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30583 invoked by alias); 15 Nov 2007 10:19:48 -0000 Received: (qmail 30569 invoked by uid 22791); 15 Nov 2007 10:19:47 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.nildram.co.uk (HELO smtp.nildram.co.uk) (195.149.33.74) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 15 Nov 2007 10:19:42 +0000 Received: from firetop.home (84-12-20-70.dyn.gotadsl.co.uk [84.12.20.70]) by smtp.nildram.co.uk (Postfix) with ESMTP id 344004C07E for ; Thu, 15 Nov 2007 10:19:38 +0000 (GMT) Received: from richard by firetop.home with local (Exim 4.63) (envelope-from ) id 1Isbox-0006e3-H2 for gcc-patches@gcc.gnu.org; Thu, 15 Nov 2007 10:19:39 +0000 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rsandifo@nildram.co.uk Subject: RFA: Fix tracking of pass-by-reference parameters References: <200711072150.47455.ebotcazou@libertysurf.fr> <873avfjn23.fsf@firetop.home> <200711121559.01676.ebotcazou@libertysurf.fr> <87mytfu8cc.fsf@firetop.home> Date: Thu, 15 Nov 2007 12:44:00 -0000 In-Reply-To: <87mytfu8cc.fsf@firetop.home> (Richard Sandiford's message of "Thu\, 15 Nov 2007 10\:11\:15 +0000") Message-ID: <87ir43u7yc.fsf_-_@firetop.home> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg00843.txt.bz2 This is the follow-up to: http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00835.html As explained in that message, if the ABI requires an argument to be passed by reference, we attach register attributes to the pointer and memory attributes to the dereferenced pointer. The debugging output then treats the pointer as part of the deferenced value. Bootstrapped & regression-tested on x86_64-linux-gnu. Also regression-tested on mipsisa64-elf, where it fixes the debug output for at least: > - gcc.c-torture/compile/941019-1.c > - gcc.c-torture/compile/vector-2.c For example, in gcc.c-torture/compile/941019-1.c, we said that the real part of "cld" was in (reg:DI $4) and the imaginary part was in (mem:DI (plus:DI (reg:DI $4) (const_int 4))). We now correctly say that the whole of cld is at (mem:CDI (reg:DI $4)). OK to install? Richard gcc/ * tree.h (set_decl_incoming_rtl): Add a by_reference_p parameter. * emit-rtl.c (set_decl_incoming_rtl): Likewise. Don't set the rtl's register attributes when the parameter is true. * function.c (assign_parms_unsplit_complex, assign_parms) (expand_function_start): Update calls to set_decl_incoming_rtl. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2007-11-14 21:45:41.000000000 +0000 +++ gcc/tree.h 2007-11-14 21:46:47.000000000 +0000 @@ -5130,7 +5130,7 @@ #define walk_tree_without_duplicates(a,b /* Assign the RTX to declaration. */ extern void set_decl_rtl (tree, rtx); -extern void set_decl_incoming_rtl (tree, rtx); +extern void set_decl_incoming_rtl (tree, rtx, bool); /* Enum and arrays used for tree allocation stats. Keep in sync with tree.c:tree_node_kind_names. */ Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2007-11-14 21:45:40.000000000 +0000 +++ gcc/emit-rtl.c 2007-11-14 21:46:47.000000000 +0000 @@ -1044,13 +1044,14 @@ set_decl_rtl (tree t, rtx x) set_reg_attrs_for_decl_rtl (t, x); } -/* Assign the RTX X to parameter declaration T. */ +/* Assign the RTX X to parameter declaration T. BY_REFERENCE_P is true + if the ABI requires the parameter to be passed by reference. */ void -set_decl_incoming_rtl (tree t, rtx x) +set_decl_incoming_rtl (tree t, rtx x, bool by_reference_p) { DECL_INCOMING_RTL (t) = x; - if (x) + if (x && !by_reference_p) set_reg_attrs_for_decl_rtl (t, x); } Index: gcc/function.c =================================================================== --- gcc/function.c 2007-11-14 21:45:40.000000000 +0000 +++ gcc/function.c 2007-11-14 21:46:47.000000000 +0000 @@ -2970,13 +2970,13 @@ assign_parms_unsplit_complex (struct ass imag = gen_lowpart_SUBREG (inner, imag); } tmp = gen_rtx_CONCAT (DECL_MODE (parm), real, imag); - set_decl_incoming_rtl (parm, tmp); + set_decl_incoming_rtl (parm, tmp, false); fnargs = TREE_CHAIN (fnargs); } else { SET_DECL_RTL (parm, DECL_RTL (fnargs)); - set_decl_incoming_rtl (parm, DECL_INCOMING_RTL (fnargs)); + set_decl_incoming_rtl (parm, DECL_INCOMING_RTL (fnargs), false); /* Set MEM_EXPR to the original decl, i.e. to PARM, instead of the copy of decl, i.e. FNARGS. */ @@ -3032,7 +3032,7 @@ assign_parms (tree fndecl) } /* Record permanently how this parm was passed. */ - set_decl_incoming_rtl (parm, data.entry_parm); + set_decl_incoming_rtl (parm, data.entry_parm, data.passed_pointer); /* Update info on where next arg arrives in registers. */ FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode, @@ -4252,7 +4252,7 @@ expand_function_start (tree subr) tree parm = cfun->static_chain_decl; rtx local = gen_reg_rtx (Pmode); - set_decl_incoming_rtl (parm, static_chain_incoming_rtx); + set_decl_incoming_rtl (parm, static_chain_incoming_rtx, false); SET_DECL_RTL (parm, local); mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));