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]

(C++) another type_info waste patch


Even though with my last patch, we avoid emitting tinfo functions that
aren't really needed, we would emit the tinfo nodes and any constants used
by the function (such as the name of the class).  This patch kludges around
that until some missing functionality is added to the compiler.

1999-11-13  Jason Merrill  <jason@yorick.cygnus.com>

	* rtti.c (get_tinfo_fn_unused): Split out from get_tinfo_fn.
	* class.c (set_rtti_entry): Use it.

Index: rtti.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/rtti.c,v
retrieving revision 1.46
diff -c -p -r1.46 rtti.c
*** rtti.c	1999/11/12 22:25:42	1.46
--- rtti.c	1999/11/13 09:33:24
*************** get_tinfo_var (type)
*** 361,368 ****
    return tdecl;
  }
  
  tree
! get_tinfo_fn (type)
       tree type;
  {
    tree name;
--- 361,379 ----
    return tdecl;
  }
  
+ /* Returns the decl for a function which will return a type_info node for
+    TYPE.  This version does not mark the function used, for use in
+    set_rtti_entry; for the vtable case, we'll get marked in
+    finish_vtable_vardecl, when we know that we want to be emitted.
+ 
+    We do this to avoid emitting the tinfo node itself, since we don't
+    currently support DECL_DEFER_OUTPUT for variables.  Also, we don't
+    associate constant pools with their functions properly, so we would
+    emit string constants and such even though we don't emit the actual
+    function.  When those bugs are fixed, this function should go away.  */
+ 
  tree
! get_tinfo_fn_unused (type)
       tree type;
  {
    tree name;
*************** get_tinfo_fn (type)
*** 391,400 ****
  
    pushdecl_top_level (d);
    make_function_rtl (d);
-   mark_used (d);
    mark_inline_for_output (d);
    pop_obstacks ();
  
    return d;
  }
  
--- 402,421 ----
  
    pushdecl_top_level (d);
    make_function_rtl (d);
    mark_inline_for_output (d);
    pop_obstacks ();
  
+   return d;
+ }
+ 
+ /* Likewise, but also mark it used.  Called by various EH and RTTI code.  */
+ 
+ tree
+ get_tinfo_fn (type)
+      tree type;
+ {
+   tree d = get_tinfo_fn_unused (type);
+   mark_used (d);
    return d;
  }
  
Index: class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/class.c,v
retrieving revision 1.198
diff -c -p -r1.198 class.c
*** class.c	1999/11/07 22:21:28	1.198
--- class.c	1999/11/13 09:33:24
*************** set_rtti_entry (virtuals, offset, type)
*** 652,658 ****
      return;
  
    if (flag_rtti)
!     fn = get_tinfo_fn (type);
    else
      /* If someone tries to get RTTI information for a type compiled
         without RTTI, they're out of luck.  By calling __pure_virtual
--- 652,658 ----
      return;
  
    if (flag_rtti)
!     fn = get_tinfo_fn_unused (type);
    else
      /* If someone tries to get RTTI information for a type compiled
         without RTTI, they're out of luck.  By calling __pure_virtual
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.344
diff -c -p -r1.344 cp-tree.h
*** cp-tree.h	1999/11/10 17:57:21	1.344
--- cp-tree.h	1999/11/13 09:33:25
*************** cp-tree.h		PROTO(
*** 3792,3797 ****
--- 3792,3798 ----
  extern tree build_typeid			PROTO((tree));
  extern tree build_x_typeid			PROTO((tree));
  extern tree get_tinfo_fn			PROTO((tree));
+ extern tree get_tinfo_fn_unused			PROTO((tree));
  extern tree get_typeid				PROTO((tree));
  extern tree get_typeid_1			PROTO((tree));
  extern tree build_dynamic_cast			PROTO((tree, tree));


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