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: Patch to block removal optimization


As per my last mail, this prevents us from removing the block for the
outermost {} of a function.

2000-03-04  Jason Merrill  <jason@casey.cygnus.com>

	* stmt.c (is_body_block): Move...
	* dwarfout.c, dwarf2out.c: ...from here.
	* tree.h: Declare it.
	* emit-rtl.c (remove_unncessary_notes): Don't remove the body block.
	* final.c (final_start_function): Do call remove_unnecessary_notes
	when scheduling.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.112
diff -c -p -r1.112 emit-rtl.c
*** emit-rtl.c	2000/03/04 00:48:46	1.112
--- emit-rtl.c	2000/03/04 09:27:13
*************** remove_unncessary_notes ()
*** 2711,2720 ****
  		  if (NOTE_BLOCK (prev) != NOTE_BLOCK (insn))
  		    abort ();
  
! 		  debug_ignore_block (NOTE_BLOCK (insn));
! 		  
! 		  remove_insn (prev);
! 		  remove_insn (insn);
  		  break;
  		}
  	      else if (NOTE_LINE_NUMBER (prev) == NOTE_INSN_BLOCK_END)
--- 2711,2726 ----
  		  if (NOTE_BLOCK (prev) != NOTE_BLOCK (insn))
  		    abort ();
  
! 		  /* Never delete the BLOCK for the outermost scope
! 		     of the function; we can refer to names from
! 		     that scope even if the block notes are messed up.  */
! 		  if (! is_body_block (NOTE_BLOCK (insn)))
! 		    {
! 		      debug_ignore_block (NOTE_BLOCK (insn));
! 
! 		      remove_insn (prev);
! 		      remove_insn (insn);
! 		    }
  		  break;
  		}
  	      else if (NOTE_LINE_NUMBER (prev) == NOTE_INSN_BLOCK_END)
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.156
diff -c -p -r1.156 dwarf2out.c
*** dwarf2out.c	2000/03/04 00:48:46	1.156
--- dwarf2out.c	2000/03/04 09:27:19
*************** dwarf2out.c		PARAMS ((vo
*** 2436,2442 ****
  static void add_arange			PARAMS ((tree, dw_die_ref));
  static void output_aranges		PARAMS ((void));
  static void output_line_info		PARAMS ((void));
- static int is_body_block		PARAMS ((tree));
  static dw_die_ref base_type_die		PARAMS ((tree));
  static tree root_type			PARAMS ((tree));
  static int is_base_type			PARAMS ((tree));
--- 2436,2441 ----
*************** output_line_info ()
*** 5924,5959 ****
    ASM_OUTPUT_LABEL (asm_out_file, ".LTEND");
  }
  
- /* Given a pointer to a BLOCK node return non-zero if (and only if) the node
-    in question represents the outermost pair of curly braces (i.e. the "body
-    block") of a function or method.
- 
-    For any BLOCK node representing a "body block" of a function or method, the
-    BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
-    represents the outermost (function) scope for the function or method (i.e.
-    the one which includes the formal parameters).  The BLOCK_SUPERCONTEXT of
-    *that* node in turn will point to the relevant FUNCTION_DECL node. */
- 
- static inline int
- is_body_block (stmt)
-      register tree stmt;
- {
-   if (TREE_CODE (stmt) == BLOCK)
-     {
-       register tree parent = BLOCK_SUPERCONTEXT (stmt);
- 
-       if (TREE_CODE (parent) == BLOCK)
- 	{
- 	  register tree grandparent = BLOCK_SUPERCONTEXT (parent);
- 
- 	  if (TREE_CODE (grandparent) == FUNCTION_DECL)
- 	    return 1;
- 	}
-     }
- 
-   return 0;
- }
- 
  /* Given a pointer to a tree node for some base type, return a pointer to
     a DIE that describes the given type.
  
--- 5923,5928 ----
Index: dwarfout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarfout.c,v
retrieving revision 1.58
diff -c -p -r1.58 dwarfout.c
*** dwarfout.c	2000/03/04 00:48:46	1.58
--- dwarfout.c	2000/03/04 09:27:23
*************** dwarfout.c		PARAMS 
*** 318,324 ****
  static void output_unsigned_leb128	PARAMS ((unsigned long));
  static void output_signed_leb128	PARAMS ((long));
  #endif
- static inline int is_body_block		PARAMS ((tree));
  static int fundamental_type_code	PARAMS ((tree));
  static tree root_type_1			PARAMS ((tree, int));
  static tree root_type			PARAMS ((tree));
--- 318,323 ----
*************** output_signed_leb128 (value)
*** 1281,1317 ****
  #endif
  
  /**************** utility functions for attribute functions ******************/
- 
- /* Given a pointer to a BLOCK node return non-zero if (and only if) the
-    node in question represents the outermost pair of curly braces (i.e.
-    the "body block") of a function or method.
- 
-    For any BLOCK node representing a "body block" of a function or method,
-    the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
-    which represents the outermost (function) scope for the function or
-    method (i.e. the one which includes the formal parameters).  The
-    BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
-    FUNCTION_DECL node.
- */
- 
- static inline int
- is_body_block (stmt)
-      register tree stmt;
- {
-   if (TREE_CODE (stmt) == BLOCK)
-     {
-       register tree parent = BLOCK_SUPERCONTEXT (stmt);
- 
-       if (TREE_CODE (parent) == BLOCK)
- 	{
- 	  register tree grandparent = BLOCK_SUPERCONTEXT (parent);
- 
- 	  if (TREE_CODE (grandparent) == FUNCTION_DECL)
- 	    return 1;
- 	}
-     }
-   return 0;
- }
  
  /* Given a pointer to a tree node for some type, return a Dwarf fundamental
     type code for the given type.
--- 1280,1285 ----
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.124
diff -c -p -r1.124 stmt.c
*** stmt.c	2000/02/21 23:27:01	1.124
--- stmt.c	2000/03/04 09:27:28
*************** expand_end_target_temps ()
*** 3310,3315 ****
--- 3310,3345 ----
    pop_temp_slots ();
  }
  
+ /* Given a pointer to a BLOCK node return non-zero if (and only if) the node
+    in question represents the outermost pair of curly braces (i.e. the "body
+    block") of a function or method.
+ 
+    For any BLOCK node representing a "body block" of a function or method, the
+    BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
+    represents the outermost (function) scope for the function or method (i.e.
+    the one which includes the formal parameters).  The BLOCK_SUPERCONTEXT of
+    *that* node in turn will point to the relevant FUNCTION_DECL node. */
+ 
+ int
+ is_body_block (stmt)
+      register tree stmt;
+ {
+   if (TREE_CODE (stmt) == BLOCK)
+     {
+       tree parent = BLOCK_SUPERCONTEXT (stmt);
+ 
+       if (parent && TREE_CODE (parent) == BLOCK)
+ 	{
+ 	  tree grandparent = BLOCK_SUPERCONTEXT (parent);
+ 
+ 	  if (grandparent && TREE_CODE (grandparent) == FUNCTION_DECL)
+ 	    return 1;
+ 	}
+     }
+ 
+   return 0;
+ }
+ 
  /* Mark top block of block_stack as an implicit binding for an
     exception region.  This is used to prevent infinite recursion when
     ending a binding with expand_end_bindings.  It is only ever called
Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.130
diff -c -p -r1.130 tree.h
*** tree.h	2000/03/03 02:27:12	1.130
--- tree.h	2000/03/04 09:27:30
*************** tree.h			PARAMS
*** 2178,2183 ****
--- 2178,2185 ----
  extern void warn_about_unused_variables         PARAMS ((tree));
  extern void start_cleanup_deferral		PARAMS ((void));
  extern void end_cleanup_deferral		PARAMS ((void));
+ extern int is_body_block			PARAMS ((tree));
+ 
  extern void mark_block_as_eh_region		PARAMS ((void));
  extern void mark_block_as_not_eh_region		PARAMS ((void));
  extern int is_eh_region				PARAMS ((void));
Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.115
diff -c -p -r1.115 final.c
*** final.c	2000/03/04 00:48:46	1.115
--- final.c	2000/03/04 09:27:33
*************** final_start_function (first, file, optim
*** 1644,1653 ****
    if (write_symbols)
      {
        number_blocks (current_function_decl);
!       /* Scheduling packs block notes together at the top of a basic block,
! 	 so we can't learn anything from them.  */
!       if (! flag_schedule_insns && ! flag_schedule_insns_after_reload)
! 	remove_unncessary_notes ();
        /* We never actually put out begin/end notes for the top-level
  	 block in the function.  But, conceptually, that block is
  	 always needed.  */
--- 1644,1650 ----
    if (write_symbols)
      {
        number_blocks (current_function_decl);
!       remove_unncessary_notes ();
        /* We never actually put out begin/end notes for the top-level
  	 block in the function.  But, conceptually, that block is
  	 always needed.  */

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