This is the mail archive of the 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]

RFA: Fix tracking of pass-by-reference parameters

This is the follow-up to:

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?


	* 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.  */
-set_decl_incoming_rtl (tree t, rtx x)
+set_decl_incoming_rtl (tree t, rtx x, bool by_reference_p)
-  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);
 	  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))));

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