This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: unsharing rtl too early


On May 20, 2000, Richard Henderson <rth@cygnus.com> wrote:

> On Sat, May 20, 2000 at 07:24:42AM -0300, Alexandre Oliva wrote:
>> * emit-rtl.c (unshare_all_rtl): Store the copied rtx.

> Bwahaha.  Yes, this is obviously ok.

Nevertheless, it was not enough to fix gcc.dg/980816-1.c, as I've
noticed a few minutes ago.  The problem was that, in the original
testcase, both variables referenced in the divmod insn were
virtual-stack-vars, not virtual-incoming-args, so they were not
unshared.

Here's a patch that arranges for decls to be unshared too, thus fixing
the testcase on mn10300.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>

	* emit-rtl.c (unshare_all_decls): New function.
	(unshare_all_rtl): Call it.

Index: gcc/emit-rtl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/emit-rtl.c,v
retrieving revision 1.153
diff -u -r1.153 emit-rtl.c
--- gcc/emit-rtl.c	2000/05/15 17:46:19	1.153
+++ gcc/emit-rtl.c	2000/05/20 19:55:28
@@ -178,6 +178,7 @@
 static rtx find_line_note		PARAMS ((rtx));
 static void mark_sequence_stack         PARAMS ((struct sequence_stack *));
 static void unshare_all_rtl_1		PARAMS ((rtx));
+static void unshare_all_decls		PARAMS ((tree));
 static hashval_t const_int_htab_hash    PARAMS ((const void *));
 static int const_int_htab_eq            PARAMS ((const void *,
 						 const void *));
@@ -1697,6 +1694,9 @@
   for (decl = DECL_ARGUMENTS (fndecl); decl; decl = TREE_CHAIN (decl))
     copy_rtx_if_shared (DECL_RTL (decl));
 
+  /* Make sure that virtual stack slots are not shared.  */
+  unshare_all_decls (DECL_INITIAL (fndecl));
+
   /* Unshare just about everything else.  */
   unshare_all_rtl_1 (insn);
   
@@ -1752,6 +1756,23 @@
 	REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
 	LOG_LINKS (insn) = copy_rtx_if_shared (LOG_LINKS (insn));
       }
+}
+
+/* Go through all virtual stack slots of a function and copy any
+   shared structure.  */
+static void
+unshare_all_decls (let)
+     tree let;
+{
+  tree t;
+
+  /* Copy shared decls.  */
+  for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t))
+    DECL_RTL (t)  = copy_rtx_if_shared (DECL_RTL (t));
+
+  /* Now process sub-blocks.  */
+  for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t))
+    unshare_all_decls (t);
 }
 
 /* Mark ORIG as in use, and return a copy of it if it was already in use.

-- 
Alexandre Oliva    Enjoy Guaranį, see http://www.ic.unicamp.br/~oliva/
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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