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]

PATCH for DECL_COMDAT in middle-end



When we reworked the C++ static initialization stuff so that it would
actually work, we removed some code in the C++ front-end that was
copied from the middle-end, and broke the middle-end code out so that
it was callable from a front-end.  In particular,
wrapup_global_declarations was exposed to front-ends.

It turns out that the C++ front-end hadn't made an *exact* copy of
this function.  This patch contains the minor tweak that the C++
front-end had added.  In particular, this patch defines DECL_COMDAT in
the middle-end.

The idea behind DECL_COMDAT is similar to DECL_ONE_ONLY, except that
there is no need to put out something which is both TREE_PUBLIC and
DECL_COMDAT unless it is really referenced.  In other words, such
things will have external linkage, but they will be created by each
translation unit which needs them, so there's no need to output them
in a translation unit which doesn't need them.

This patch is important for 1.2; cygwin will suffer performance
penalties (too many inline functions will be emitted), unless we apply
this patch (or something else which solves the problem.)

OK?

-- 
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Sun May  2 14:02:21 1999  Mark Mitchell  <mark@codesourcery.com>

	* tree.h (struct tree_decl): Add comdat_flag.
	(DECL_COMDAT): Define it.
	* toplev.c (wrapup_global_declarations): Don't output a
	DECL_COMDAT function just because it's public.

Index: tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tree.h,v
retrieving revision 1.70
diff -u -p -r1.70 tree.h
--- tree.h	1999/03/06 05:34:16	1.70
+++ tree.h	1999/05/02 20:58:45
@@ -1246,6 +1246,17 @@ struct tree_type
    multiple translation units should be merged.  */
 #define DECL_ONE_ONLY(NODE) (DECL_CHECK (NODE)->decl.transparent_union)
 
+/* Used in a DECL to indicate that, even if it TREE_PUBLIC, it need
+   not be put out unless it is needed in this translation unit.
+   Entities like this are shared across translation units (like weak
+   entities), but are guaranteed to be generated by any translation
+   unit that needs them, and therefore need not be put out anywhere
+   where they are not needed.  DECL_COMDAT is just a hint to the
+   back-end; it is up to front-ends which set this flag to ensure
+   that there will never be any harm, other than bloat, in putting out
+   something which is DECL_COMDAT.  */
+#define DECL_COMDAT(NODE) (DECL_CHECK (NODE)->decl.comdat_flag)
+
 /* Used in FUNCTION_DECLs to indicate that function entry and exit should
    be instrumented with calls to support routines.  */
 #define DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT(NODE) ((NODE)->decl.no_instrument_function_entry_exit)
@@ -1321,6 +1332,7 @@ struct tree_decl
   unsigned non_addr_const_p : 1;
   unsigned no_instrument_function_entry_exit : 1;
   unsigned no_check_memory_usage : 1;
+  unsigned comdat_flag : 1;
 
   /* For a FUNCTION_DECL, if inline, this is the size of frame needed.
      If built-in, this is the code for which built-in function.
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.181
diff -u -p -r1.181 toplev.c
--- toplev.c	1999/04/26 16:02:57	1.181
+++ toplev.c	1999/05/02 20:58:48
@@ -2753,7 +2753,7 @@ wrapup_global_declarations (vec, len)
 	      && DECL_INITIAL (decl) != 0
 	      && DECL_SAVED_INSNS (decl) != 0
 	      && (flag_keep_inline_functions
-		  || TREE_PUBLIC (decl)
+		  || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
 		  || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
 	    {
 	      reconsider = 1;



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