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]
Other format: [Raw text]

Re: [C++ patch] Fix TREE_USED flag in some cases


> 
> Actually I can not find such macro anywhere.  Am I supposed to invent
> it? (it would probably be function in tree.c as nops can be chained,
> right?)
OK, I've implemented the function.  The attached patch has survived i386
bootstrap/regtesting.

Mon Jun 23 17:45:02 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* tree.c (skip_nops): New function.
	* tree.h (skip_nops): Declare.

	* decl.c (register_dtor_fn): Mark cleanup as used.
	* decl2.c (mark_vtable_entries): Skip nops.
	* rtti.c (get_tinfo_ptr): Mark tinfo as used.
	(build_dynamic_cast_1): Likewise.
	(tinfo_base_init): Likewise.
	(emit_tinfo_decl): Likewise.
Index: gcc/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.309
diff -c -3 -p -r1.309 tree.c
*** gcc/tree.c	16 Jun 2003 21:41:06 -0000	1.309
--- gcc/tree.c	23 Jun 2003 16:37:31 -0000
*************** initializer_zerop (init)
*** 5189,5192 ****
--- 5189,5202 ----
      }
  }
  
+ /* Return inner expression of possible NOP_EXPR chain.  */
+ tree
+ skip_nops (exp)
+      tree exp;
+ {
+   while (TREE_CODE (exp) == NOP_EXPR)
+     exp = TREE_OPERAND (exp, 0);
+   return exp;
+ }
+ 
  #include "gt-tree.h"
Index: gcc/tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.415
diff -c -3 -p -r1.415 tree.h
*** gcc/tree.h	20 Jun 2003 09:08:15 -0000	1.415
--- gcc/tree.h	23 Jun 2003 16:37:32 -0000
*************** extern void init_ttree			PARAMS ((void))
*** 2817,2822 ****
--- 2817,2823 ----
  extern void build_common_tree_nodes	PARAMS ((int));
  extern void build_common_tree_nodes_2	PARAMS ((int));
  extern tree build_range_type		PARAMS ((tree, tree, tree));
+ extern tree skip_nops			PARAMS ((tree));
  
  /* In function.c */
  extern void setjmp_protect_args		PARAMS ((void));
Index: gcc/cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1070
diff -c -3 -p -r1.1070 decl.c
*** gcc/cp/decl.c	21 Jun 2003 13:09:05 -0000	1.1070
--- gcc/cp/decl.c	23 Jun 2003 16:37:33 -0000
*************** register_dtor_fn (tree decl)
*** 8486,8491 ****
--- 8486,8492 ----
  
    /* Call atexit with the cleanup function.  */
    cxx_mark_addressable (cleanup);
+   mark_used (cleanup);
    cleanup = build_unary_op (ADDR_EXPR, cleanup, 0);
    if (flag_use_cxa_atexit)
      {
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.630
diff -c -3 -p -r1.630 decl2.c
*** gcc/cp/decl2.c	20 Jun 2003 00:48:40 -0000	1.630
--- gcc/cp/decl2.c	23 Jun 2003 16:37:33 -0000
*************** mark_vtable_entries (tree decl)
*** 1391,1399 ****
  
    for (; entries; entries = TREE_CHAIN (entries))
      {
!       tree fnaddr = TREE_VALUE (entries);
        tree fn;
!       
        if (TREE_CODE (fnaddr) != ADDR_EXPR
  	  && TREE_CODE (fnaddr) != FDESC_EXPR)
  	/* This entry is an offset: a virtual base class offset, a
--- 1391,1399 ----
  
    for (; entries; entries = TREE_CHAIN (entries))
      {
!       tree fnaddr = skip_nops (TREE_VALUE (entries));
        tree fn;
! 
        if (TREE_CODE (fnaddr) != ADDR_EXPR
  	  && TREE_CODE (fnaddr) != FDESC_EXPR)
  	/* This entry is an offset: a virtual base class offset, a
Index: gcc/cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.164
diff -c -3 -p -r1.164 rtti.c
*** gcc/cp/rtti.c	20 Jun 2003 00:48:41 -0000	1.164
--- gcc/cp/rtti.c	23 Jun 2003 16:37:33 -0000
*************** get_tinfo_decl (tree type)
*** 387,394 ****
  static tree
  get_tinfo_ptr (tree type)
  {
    return build_nop (type_info_ptr_type, 
! 		    build_address (get_tinfo_decl (type)));
  }
  
  /* Return the type_info object for TYPE.  */
--- 387,397 ----
  static tree
  get_tinfo_ptr (tree type)
  {
+   tree decl = get_tinfo_decl (type);
+ 
+   mark_used (decl);
    return build_nop (type_info_ptr_type, 
! 		    build_address (decl));
  }
  
  /* Return the type_info object for TYPE.  */
*************** build_dynamic_cast_1 (tree type, tree ex
*** 612,619 ****
  
  	  target_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  	  static_type = TYPE_MAIN_VARIANT (TREE_TYPE (exprtype));
! 	  td2 = build_unary_op (ADDR_EXPR, get_tinfo_decl (target_type), 0);
! 	  td3 = build_unary_op (ADDR_EXPR, get_tinfo_decl (static_type), 0);
  
            /* Determine how T and V are related.  */
            boff = get_dynamic_cast_base_type (static_type, target_type);
--- 615,626 ----
  
  	  target_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  	  static_type = TYPE_MAIN_VARIANT (TREE_TYPE (exprtype));
! 	  td2 = get_tinfo_decl (target_type);
! 	  mark_used (td2);
! 	  td2 = build_unary_op (ADDR_EXPR, td2, 0);
! 	  td3 = get_tinfo_decl (static_type);
! 	  mark_used (td3);
! 	  td3 = build_unary_op (ADDR_EXPR, td3, 0);
  
            /* Determine how T and V are related.  */
            boff = get_dynamic_cast_base_type (static_type, target_type);
*************** tinfo_base_init (tree desc, tree target)
*** 769,774 ****
--- 776,782 ----
      SET_DECL_ASSEMBLER_NAME (name_decl,
  			     mangle_typeinfo_string_for_type (target));
      DECL_INITIAL (name_decl) = name_string;
+     mark_used (name_decl);
      pushdecl_top_level_and_finish (name_decl, name_string);
    }
  
*************** emit_tinfo_decl (tree decl)
*** 1461,1466 ****
--- 1469,1475 ----
      DECL_COMDAT (decl) = 0;
  
    DECL_INITIAL (decl) = var_init;
+   mark_used (decl);
    cp_finish_decl (decl, var_init, NULL_TREE, 0);
    /* cp_finish_decl will have dealt with linkage.  */
    


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