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]

Fix unused-2.c failure


Hi,
the unused-2.c failure is caused by latent bug in integreate.c on handling
deleted labels.  It didn't show before, as we did deleted labels only
when merged blocks, while now we delete all unused labels aggressibly.

The integreate_decl_tree copies DECL_RTL by copy_rtx_and_substitute.
When it reaches DELETED_LABEL, it returns insn_map of the UID, that is
NULL, as isnsn hasn't been copied yet, so the DECL_RTL later thinks
that RTL wasn't generated yet causing crash in varasm.c

For CODE_LABELs, everything works fluently, as copy_rtx_and_substitute
knows how to generate it early and later just emits the existing label.

The patch makes handling of NOTE_INSN_DELETED_LABEL equivalent to the
CODE_LABELs, at the end, the CODE_LABELs are emitted and eventually zapped
again by cfg_cleanup.

Bootstrapping/regtesting i686.

Honza
  
Thu Jul 19 17:36:20 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* integrate.c (expand_inline_function): Make label_map indexed
	by INSN_UID instead of LABEL_UID.
	(copy_insn_list): Update get_label_from_map calls; handle
	NOTE_INSN_DELETED_LABEL, as if it were CODE_LABEL.
	(copy_rtx_and_substitute): Likewise; behave to NOTE_INSN_DELETED_LABEL
	identically as to CODE_LABEL.

Index: integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.152
diff -c -3 -p -r1.152 integrate.c
*** integrate.c	2001/07/18 06:35:24	1.152
--- integrate.c	2001/07/19 15:45:03
*************** expand_inline_function (fndecl, parms, t
*** 787,801 ****
    VARRAY_TREE_INIT (map->block_map, 10, "block_map");
    map->reg_map = (rtx *) xcalloc (max_regno, sizeof (rtx));
  
    /* We used to use alloca here, but the size of what it would try to
       allocate would occasionally cause it to exceed the stack limit and
       cause unpredictable core dumps.  */
    real_label_map
!     = (rtx *) xmalloc ((max_labelno) * sizeof (rtx));
    map->label_map = real_label_map;
    map->local_return_label = NULL_RTX;
  
-   inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
    map->insn_map = (rtx *) xcalloc (inl_max_uid, sizeof (rtx));
    map->min_insnno = 0;
    map->max_insnno = inl_max_uid;
--- 787,801 ----
    VARRAY_TREE_INIT (map->block_map, 10, "block_map");
    map->reg_map = (rtx *) xcalloc (max_regno, sizeof (rtx));
  
+   inl_max_uid = (inl_f->emit->x_cur_insn_uid + 1);
    /* We used to use alloca here, but the size of what it would try to
       allocate would occasionally cause it to exceed the stack limit and
       cause unpredictable core dumps.  */
    real_label_map
!     = (rtx *) xmalloc ((inl_max_uid) * sizeof (rtx));
    map->label_map = real_label_map;
    map->local_return_label = NULL_RTX;
  
    map->insn_map = (rtx *) xcalloc (inl_max_uid, sizeof (rtx));
    map->min_insnno = 0;
    map->max_insnno = inl_max_uid;
*************** expand_inline_function (fndecl, parms, t
*** 1141,1148 ****
  
    /* Initialize label_map.  get_label_from_map will actually make
       the labels.  */
!   memset ((char *) &map->label_map[min_labelno], 0,
! 	 (max_labelno - min_labelno) * sizeof (rtx));
  
    /* Make copies of the decls of the symbols in the inline function, so that
       the copies of the variables get declared in the current function.  Set
--- 1141,1148 ----
  
    /* Initialize label_map.  get_label_from_map will actually make
       the labels.  */
!   memset ((char *) map->label_map, 0,
! 	  inl_max_uid * sizeof (rtx));
  
    /* Make copies of the decls of the symbols in the inline function, so that
       the copies of the variables get declared in the current function.  Set
*************** copy_insn_list (insns, map, static_chain
*** 1545,1551 ****
  
  	case CODE_LABEL:
  	  copy = emit_label (get_label_from_map (map,
! 						 CODE_LABEL_NUMBER (insn)));
  	  LABEL_NAME (copy) = LABEL_NAME (insn);
  	  map->const_age++;
  	  break;
--- 1545,1551 ----
  
  	case CODE_LABEL:
  	  copy = emit_label (get_label_from_map (map,
! 						 INSN_UID (insn)));
  	  LABEL_NAME (copy) = LABEL_NAME (insn);
  	  map->const_age++;
  	  break;
*************** copy_insn_list (insns, map, static_chain
*** 1555,1560 ****
--- 1555,1567 ----
  	  break;
  
  	case NOTE:
+ 	  if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)
+ 	    {
+ 	      copy = emit_label (get_label_from_map (map, INSN_UID (insn)));
+ 	      map->const_age++;
+ 	      break;
+ 	    }
+ 
  	  /* NOTE_INSN_FUNCTION_END and NOTE_INSN_FUNCTION_BEG are
  	     discarded because it is important to have only one of
  	     each in the current function.
*************** copy_rtx_and_substitute (orig, map, for_
*** 1992,2008 ****
  	copy = SUBREG_REG (copy);
        return gen_rtx_fmt_e (code, VOIDmode, copy);
  
-     case CODE_LABEL:
-       LABEL_PRESERVE_P (get_label_from_map (map, CODE_LABEL_NUMBER (orig)))
- 	= LABEL_PRESERVE_P (orig);
-       return get_label_from_map (map, CODE_LABEL_NUMBER (orig));
- 
      /* We need to handle "deleted" labels that appear in the DECL_RTL
         of a LABEL_DECL.  */
      case NOTE:
!       if (NOTE_LINE_NUMBER (orig) == NOTE_INSN_DELETED_LABEL)
! 	return map->insn_map[INSN_UID (orig)];
!       break;
  
      case LABEL_REF:
        copy
--- 1999,2016 ----
  	copy = SUBREG_REG (copy);
        return gen_rtx_fmt_e (code, VOIDmode, copy);
  
      /* We need to handle "deleted" labels that appear in the DECL_RTL
         of a LABEL_DECL.  */
      case NOTE:
!       if (NOTE_LINE_NUMBER (orig) != NOTE_INSN_DELETED_LABEL)
! 	break;
! 
!       /* ... FALL THRU .... */
!     case CODE_LABEL:
!       LABEL_PRESERVE_P (get_label_from_map (map, INSN_UID (orig)))
! 	= LABEL_PRESERVE_P (orig);
!       return get_label_from_map (map, INSN_UID (orig));
! 
  
      case LABEL_REF:
        copy


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