20000131 anomolous system header warnings

Zack Weinberg zack@wolery.cumb.org
Sun Feb 6 18:14:00 GMT 2000


On Sun, Feb 06, 2000 at 07:59:33PM -0500, Brown, Rodney wrote:
> > Zack Weinberg wrote:
> > > On Fri, Feb 04, 2000 at 10:33:59PM +1100, Rodney Brown wrote:
> > > > The egcs-20000131 snapshot on i586-sco-sysv5uw7.1.0 gave 
> > lots of anomalous 
> > > > "defined but not used" warnings on include/sys/stat.h for 
> > {f,,l}stat.
> > > > These are static wrapper functions on UnixWare.
> 
> > > Try this.  It fixes the problem for me with your example, 
> > but may not
> > > be the right answer in general - there must have been some 
> > reason why
> > > we made a distinction between permanent and temporary decls here.
> 
> The current_obstack == &permanent_obstack test is used a number of times in
> tree.c - to set TREE_PERMANENT which is referenced by c-common.c and
> dwarfout.c . Doesn't the removal of end_temporary_allocation mean that
> current_obstack will remain != &permanent_obstack thereafer?

Yeah.  And it looks like that breaks some important stuff, like alias
analysis.

I need a design opinion here.  We're moving all the front ends toward
using the garbage collector.  (Looks like only Java and Chill remain
to be converted, plus the front ends not yet merged.)  That being the
case, is TREE_PERMANENT an obsolete concept?  I am guessing "yes", and
we want to eliminate all the places that test it.

A patch in that vein follows.

Another question: once Java and Chill get converted, can we throw away
the obstacks code entirely, or do we need to hold off till Pascal,
Ada, Modula-3, etc. get merged?  (When are they getting merged, anyway?)

zw

	* tree.c (make_node): Set DECL_IN_SYSTEM_HEADER irrespective
	of tree permanence.
	(make_node, copy_node, make_tree_vec, tree_cons, build1): Set
	TREE_PERMANENT only if using obstacks.
	* tree.h: Document that TREE_PERMANENT is only meaningful if
	obstacks are in use.
	* print-tree.c (print_node): Don't print 'permanent' flag if
	ggc_p.
	* dwarfout.c (output_type): If ggc_p, all types are "permanent".
	* c-common.c (c_get_alias_set): Always get a new type a new
	alias set.
	* objc/objc-act.c (build_objc_string_object): Never copy the
	string.

===================================================================
Index: tree.c
--- tree.c	2000/01/17 15:55:18	1.115
+++ tree.c	2000/02/07 02:09:05
@@ -891,6 +891,8 @@ init_tree_codes ()
 
 /* Return a newly allocated node of code CODE.
    Initialize the node's unique id and its TREE_PERMANENT flag.
+   Note that if garbage collection is in use, TREE_PERMANENT will
+   always be zero - we want to eliminate use of TREE_PERMANENT.
    For decl and type nodes, some other fields are initialized.
    The rest of the node is initialized to zero.
 
@@ -1039,6 +1041,8 @@ make_node (code)
     {
       t = (tree) obstack_alloc (obstack, length);
       memset ((PTR) t, 0, length);
+      if (obstack == &permanent_obstack)
+	TREE_PERMANENT (t) = 1;
     }
 
 #ifdef GATHER_STATISTICS
@@ -1047,8 +1051,6 @@ make_node (code)
 #endif
 
   TREE_SET_CODE (t, code);
-  if (obstack == &permanent_obstack)
-    TREE_PERMANENT (t) = 1;
 
   switch (type)
     {
@@ -1060,8 +1062,7 @@ make_node (code)
     case 'd':
       if (code != FUNCTION_DECL)
 	DECL_ALIGN (t) = 1;
-      DECL_IN_SYSTEM_HEADER (t)
-	= in_system_header && (obstack == &permanent_obstack);
+      DECL_IN_SYSTEM_HEADER (t) = in_system_header;
       DECL_SOURCE_LINE (t) = lineno;
       DECL_SOURCE_FILE (t) = 
 	(input_filename) ? input_filename : built_in_filename;
@@ -1214,7 +1215,7 @@ copy_node (node)
       TYPE_SYMTAB_ADDRESS (t) = 0;
     }
 
-  TREE_PERMANENT (t) = (current_obstack == &permanent_obstack);
+  TREE_PERMANENT (t) = (!ggc_p && current_obstack == &permanent_obstack);
 
   return t;
 }
@@ -1603,12 +1604,12 @@ make_tree_vec (len)
     {
       t = (tree) obstack_alloc (obstack, length);
       bzero ((PTR) t, length);
+      if (obstack == &permanent_obstack)
+	TREE_PERMANENT (t) = 1;
     }
 
   TREE_SET_CODE (t, TREE_VEC);
   TREE_VEC_LENGTH (t) = len;
-  if (obstack == &permanent_obstack)
-    TREE_PERMANENT (t) = 1;
 
   return t;
 }
@@ -2106,6 +2107,8 @@ tree_cons (purpose, value, chain)
     {
       node = (tree) obstack_alloc (current_obstack, sizeof (struct tree_list));
       memset (node, 0, sizeof (struct tree_common));
+      if (current_obstack == &permanent_obstack)
+	TREE_PERMANENT (node) = 1;
     }
 
 #ifdef GATHER_STATISTICS
@@ -2113,11 +2116,7 @@ tree_cons (purpose, value, chain)
   tree_node_sizes[(int)x_kind] += sizeof (struct tree_list);
 #endif
 
-
   TREE_SET_CODE (node, TREE_LIST);
-  if (current_obstack == &permanent_obstack)
-    TREE_PERMANENT (node) = 1;
-
   TREE_CHAIN (node) = chain;
   TREE_PURPOSE (node) = purpose;
   TREE_VALUE (node) = value;
@@ -3152,6 +3151,8 @@ build1 (code, type, node)
     {
       t = (tree) obstack_alloc (obstack, length);
       memset ((PTR) t, 0, length);
+      if (obstack == &permanent_obstack)
+	TREE_PERMANENT (t) = 1;
     }
 
 #ifdef GATHER_STATISTICS
@@ -3161,9 +3162,6 @@ build1 (code, type, node)
 
   TREE_TYPE (t) = type;
   TREE_SET_CODE (t, code);
-
-  if (obstack == &permanent_obstack)
-    TREE_PERMANENT (t) = 1;
 
   TREE_OPERAND (t, 0) = node;
   if (node && first_rtl_op (code) != 0)
===================================================================
Index: tree.h
--- tree.h	2000/01/27 20:46:26	1.120
+++ tree.h	2000/02/07 02:09:05
@@ -561,7 +561,9 @@ extern void tree_class_check_failed PARA
 
 /* Nonzero means permanent node;
    node will continue to exist for the entire compiler run.
-   Otherwise it will be recycled at the end of the function.  */
+   Otherwise it will be recycled at the end of the function.
+   This flag is always zero if garbage collection is in use.
+   Try not to use this.  */
 #define TREE_PERMANENT(NODE) ((NODE)->common.permanent_flag)
 
 /* In INTEGER_TYPE or ENUMERAL_TYPE nodes, means an unsigned type.
===================================================================
Index: print-tree.c
--- print-tree.c	1999/12/05 02:42:10	1.21
+++ print-tree.c	2000/02/07 02:09:05
@@ -300,7 +300,7 @@ print_node (file, prefix, node, indent)
     fputs (" used", file);
   if (TREE_RAISES (node))
     fputs (" raises", file);
-  if (TREE_PERMANENT (node))
+  if (!ggc_p && TREE_PERMANENT (node))
     fputs (" permanent", file);
   if (TREE_PUBLIC (node))
     fputs (" public", file);
===================================================================
Index: dwarfout.c
--- dwarfout.c	2000/02/01 11:00:43	1.52
+++ dwarfout.c	2000/02/07 02:09:07
@@ -4459,7 +4459,7 @@ output_type (type, containing_scope)
 	  {
 	    /* We can't do this for function-local types, and we don't need
                to.  */
-	    if (TREE_PERMANENT (type))
+	    if (ggc_p || TREE_PERMANENT (type))
 	      add_incomplete_type (type);
 	    return;	/* EARLY EXIT!  Avoid setting TREE_ASM_WRITTEN.  */
 	  }
===================================================================
Index: c-common.c
--- c-common.c	2000/02/06 03:40:45	1.92
+++ c-common.c	2000/02/07 02:09:07
@@ -3490,16 +3490,9 @@ c_get_alias_set (t)
 
   if (!TYPE_ALIAS_SET_KNOWN_P (type))
     {
-      /* Types that are not global ('permanent') are not
-	 placed in the type hash table.  Thus, there can be multiple
-	 copies of identical types in local scopes.  In the long run,
-	 all types should be permanent.  */
-      if (! TREE_PERMANENT (type))
-	TYPE_ALIAS_SET (type) = 0;
-      else
-	/* TYPE is something we haven't seen before.  Put it in a new
-	   alias set.  */
-	TYPE_ALIAS_SET (type) = new_alias_set ();
+      /* TYPE is something we haven't seen before.  Put it in a new
+	 alias set.  */
+      TYPE_ALIAS_SET (type) = new_alias_set ();
     }
 
   return TYPE_ALIAS_SET (type);
===================================================================
Index: objc/objc-act.c
--- objc/objc-act.c	2000/01/25 17:13:14	1.35
+++ objc/objc-act.c	2000/02/07 02:09:09
@@ -1354,13 +1354,6 @@ build_objc_string_object (strings)
   TREE_SET_CODE (string, STRING_CST);
   length = TREE_STRING_LENGTH (string) - 1;
 
-  if (! flag_next_runtime)
-    {
-      if (! TREE_PERMANENT (strings))
-	string = my_build_string (length + 1,
-				  TREE_STRING_POINTER (string));
-    }
-
   /* & ((NXConstantString) {0, string, length})  */
 
   initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));


More information about the Gcc-bugs mailing list