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

Jan Hubicka hubicka@ucw.cz
Mon Jun 23 17:02:00 GMT 2003


> On Mon, Jun 23, 2003 at 05:57:56PM +0200, Jan Hubicka wrote:
> > > Use SKIP_NOPS.
> > 
> > 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?)
> 
> STRIP_NOPS?
Funny, I was searhing for variaous alternatives for the name but didn't
get into this one.  Here is udpated patch I am testing once over.  OK?


Mon Jun 23 17:45:02 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* 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/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 = STRIP_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.  */
    



More information about the Gcc-patches mailing list