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++ PATCH: restore tree-based inlining memory savings



This patch:

  2000-01-06  Jason Merrill  <jason@casey.cygnus.com>

	* cp-tree.h (DECL_NEEDED_P): Also true if !DECL_COMDAT.
	* decl2.c (finish_vtable_vardecl): Don't check !DECL_COMDAT.
	(finish_file): Likewise.

broke the property that tree-based inlining prevents the generation of
RTL for inline functions that do not need to be put out.  It came with
this commentary:

  1) DECL_NEEDED_P is always followed by || !DECL_COMDAT, so I moved that test
     into the macro.

but that was never true in expand_body, which did:

      && !DECL_NEEDED_P (fn)

to decide whether or not to inline things.

I fixed this by checking !DECL_COMDAT only if at_eof; before that
point, we can't expect import_export_decl to have been called.

There are a few other miscellaneous cleanups in this patch.

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

2000-02-26  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (DECL_NEEDED_P): Tweak to correct usage before EOF.
	(import_export_class): Remove declaration.
	* decl2.c (import_export_class): Make it static.
	* dump.c (dequeue_and_dump): Handle PREDECREMENT_EXPR,
	PREINCREMENT_EXPR, POSTDECREMENT_EXPR, POSTINCREMENT_EXPR,
	EXPR_WITH_FILE_LOCATION.
	* lex.c (check_newline): Tweak filename/lineno setting.
	* semantics.c (begin_while_stmt): Fix typo in comment.
	
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.407
diff -c -p -r1.407 cp-tree.h
*** cp-tree.h	2000/02/22 07:25:27	1.407
--- cp-tree.h	2000/02/27 02:00:27
*************** extern int flag_new_for_scope;
*** 2878,2886 ****
     definition.  This is true when the back-end tells us that
     the symbol has been referenced in the generated code.  If, however,
     we are not generating code, then it is also true when a symbol has
!    just been used somewhere, even if it's not really needed.  */
  #define DECL_NEEDED_P(DECL)					\
!   (! DECL_COMDAT (DECL)						\
     || (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL))))	\
     || (flag_syntax_only && TREE_USED ((DECL))))
  
--- 2878,2888 ----
     definition.  This is true when the back-end tells us that
     the symbol has been referenced in the generated code.  If, however,
     we are not generating code, then it is also true when a symbol has
!    just been used somewhere, even if it's not really needed.  We need
!    anything that isn't comdat, but we don't know for sure whether or
!    not something is comdat until end-of-file.  */
  #define DECL_NEEDED_P(DECL)					\
!   ((at_eof && !DECL_COMDAT (DECL))				\
     || (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL))))	\
     || (flag_syntax_only && TREE_USED ((DECL))))
  
*************** extern void finish_builtin_type			PARAMS
*** 3831,3837 ****
  extern tree coerce_new_type			PARAMS ((tree));
  extern tree coerce_delete_type			PARAMS ((tree));
  extern void comdat_linkage			PARAMS ((tree));
- extern void import_export_class			PARAMS ((tree));
  extern void import_export_vtable		PARAMS ((tree, tree, int));
  extern void import_export_decl			PARAMS ((tree));
  extern tree build_cleanup			PARAMS ((tree));
--- 3833,3838 ----
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.311
diff -c -p -r1.311 decl2.c
*** decl2.c	2000/02/22 07:25:28	1.311
--- decl2.c	2000/02/27 02:00:31
*************** static int generate_ctor_and_dtor_functi
*** 90,95 ****
--- 90,96 ----
                                    PARAMS ((splay_tree_node, void *));
  static tree prune_vars_needing_no_initialization PARAMS ((tree));
  static void write_out_vars PARAMS ((tree));
+ static void import_export_class	PARAMS ((tree));
  
  extern int current_class_depth;
  
*************** import_export_vtable (decl, type, final)
*** 2439,2450 ****
  /* Determine whether or not we want to specifically import or export CTYPE,
     using various heuristics.  */
  
! void
  import_export_class (ctype)
       tree ctype;
  {
    /* -1 for imported, 1 for exported.  */
    int import_export = 0;
  
    if (CLASSTYPE_INTERFACE_KNOWN (ctype))
      return;
--- 2440,2458 ----
  /* Determine whether or not we want to specifically import or export CTYPE,
     using various heuristics.  */
  
! static void
  import_export_class (ctype)
       tree ctype;
  {
    /* -1 for imported, 1 for exported.  */
    int import_export = 0;
+ 
+   /* It only makes sense to call this function at EOF.  The reason is
+      that this function looks at whether or not the first non-inline
+      non-abstract virtual member function has been defined in this
+      translation unit.  But, we can't possibly know that until we've
+      seen the entire translation unit.  */
+   my_friendly_assert (at_eof, 20000226);
  
    if (CLASSTYPE_INTERFACE_KNOWN (ctype))
      return;
Index: cp/dump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/dump.c,v
retrieving revision 1.34
diff -c -p -r1.34 dump.c
*** dump.c	2000/02/17 20:45:49	1.34
--- dump.c	2000/02/27 02:00:31
*************** dequeue_and_dump (di)
*** 804,809 ****
--- 804,813 ----
      case COMPONENT_REF:
      case COMPOUND_EXPR:
      case ARRAY_REF:
+     case PREDECREMENT_EXPR:
+     case PREINCREMENT_EXPR:
+     case POSTDECREMENT_EXPR:
+     case POSTINCREMENT_EXPR:
        /* These nodes are binary, but do not have code class `2'.  */
        dump_child ("op 0", TREE_OPERAND (t, 0));
        dump_child ("op 1", TREE_OPERAND (t, 1));
*************** dequeue_and_dump (di)
*** 857,862 ****
--- 861,870 ----
        dump_child ("fn", TREE_OPERAND (t, 0));
        dump_child ("args", TREE_OPERAND (t, 1));
        dump_child ("decl", TREE_OPERAND (t, 2));
+       break;
+       
+     case EXPR_WITH_FILE_LOCATION:
+       dump_child ("expr", EXPR_WFL_NODE (t));
        break;
  
      default:
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.179
diff -c -p -r1.179 lex.c
*** lex.c	2000/02/25 01:36:03	1.179
--- lex.c	2000/02/27 02:00:34
*************** linenum:
*** 2629,2640 ****
  
  	  pop_srcloc ();
  	  input_file_stack->name = new_file;
- 	  lineno = l;
  	  debug_end_source_file (input_file_stack->line);
  	}
        else
  	error ("#-lines for entering and leaving files don't match");
      }
  
    extract_interface_info ();
  
--- 2629,2642 ----
  
  	  pop_srcloc ();
  	  input_file_stack->name = new_file;
  	  debug_end_source_file (input_file_stack->line);
  	}
        else
  	error ("#-lines for entering and leaving files don't match");
      }
+ 
+   input_filename = new_file;
+   lineno = l;
  
    extract_interface_info ();
  
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.126
diff -c -p -r1.126 semantics.c
*** semantics.c	2000/02/22 07:25:31	1.126
--- semantics.c	2000/02/27 02:00:43
*************** begin_while_stmt ()
*** 281,287 ****
    return r;
  }
  
! /* Process the COND of an if-statement, which may be given by
     WHILE_STMT.  */
  
  void 
--- 281,287 ----
    return r;
  }
  
! /* Process the COND of a while-statement, which may be given by
     WHILE_STMT.  */
  
  void 

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