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]

Disappearing labels fix



This is a slight rework of a patch Bernd installed into the gcc-2.95.x tree; it
fixes a bug Mark ran into in a linux-hpux cross compiler (compiler abort due to
mucking up reference counts on labels).  It's likely the abort would happen 
hpux native when using the HP assembler instead of GAS, so I consider it 
important
enough to go ahead and fix on the gcc-3.0 branch.

David E. probably recalls that Bernd's original patch caused indigestion on the
ppc-aix port.  So as part of testing this patch I also bootstrapped ppc-aix
(as well as ia32-linux and PA32 hpux).

	* flow.c (propagate_block_delete_insn): Handle deletion of ADDR_VEC
	and ADDR_DIFF_VEC insns when the proceeding CODE_LABEL was put
	into the constant pool.
	* jump.c (jump_optimize_1): Remove barrier successors after all
	the LABEL_NUSES counds have been computed.
	(delete_barrier_successors): When deleting a tablejump insn, also
	delete the jump table it uses.
	* varasm.c (force_const_mem): Set LABEL_PRESERVE_P when forcing a
	label into memory.


Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.374.2.5
diff -c -3 -p -r1.374.2.5 flow.c
*** flow.c	2001/04/21 18:43:39	1.374.2.5
--- flow.c	2001/04/28 16:24:17
*************** propagate_block_delete_insn (bb, insn)
*** 3716,3722 ****
        rtx label = XEXP (inote, 0);
        rtx next;
  
!       if (LABEL_NUSES (label) == 1
  	  && (next = next_nonnote_insn (label)) != NULL
  	  && GET_CODE (next) == JUMP_INSN
  	  && (GET_CODE (PATTERN (next)) == ADDR_VEC
--- 3716,3725 ----
        rtx label = XEXP (inote, 0);
        rtx next;
  
!       /* The label may be forced if it has been put in the constant
! 	 pool.  If that is the only use we must discard the table
! 	 jump following it, but not the label itself.  */
!       if (LABEL_NUSES (label) == 1 + LABEL_PRESERVE_P (label)
  	  && (next = next_nonnote_insn (label)) != NULL
  	  && GET_CODE (next) == JUMP_INSN
  	  && (GET_CODE (PATTERN (next)) == ADDR_VEC
Index: jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.153.2.3
diff -c -3 -p -r1.153.2.3 jump.c
*** jump.c	2001/04/21 18:43:39	1.153.2.3
--- jump.c	2001/04/28 16:24:21
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 218,226 ****
    if (flag_exceptions && cross_jump)
      init_insn_eh_region (f, max_uid);
  
-   if (! mark_labels_only)
-     delete_barrier_successors (f);
- 
    /* Leave some extra room for labels and duplicate exit test insns
       we make.  */
    max_jump_chain = max_uid * 14 / 10;
--- 218,223 ----
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 245,250 ****
--- 242,250 ----
      if (GET_CODE (XEXP (insn, 0)) == CODE_LABEL)
        LABEL_NUSES (XEXP (insn, 0))++;
  
+   if (! mark_labels_only)
+     delete_barrier_successors (f);
+ 
    /* Quit now if we just wanted to rebuild the JUMP_LABEL and REG_LABEL
       notes and recompute LABEL_NUSES.  */
    if (mark_labels_only)
*************** delete_barrier_successors (f)
*** 830,836 ****
  
  	  while (insn != 0 && GET_CODE (insn) != CODE_LABEL)
  	    {
! 	      if (GET_CODE (insn) == NOTE
  		  && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END)
  		insn = NEXT_INSN (insn);
  	      else
--- 830,853 ----
  
  	  while (insn != 0 && GET_CODE (insn) != CODE_LABEL)
  	    {
! 	      if (GET_CODE (insn) == JUMP_INSN)
! 		{
! 		  /* Detect when we're deleting a tablejump; get rid of
! 		     the jump table as well.  */
! 		  rtx next1 = next_nonnote_insn (insn);
! 		  rtx next2 = next1 ? next_nonnote_insn (next1) : 0;
! 		  if (next2 && GET_CODE (next1) == CODE_LABEL
! 		      && GET_CODE (next2) == JUMP_INSN
! 		      && (GET_CODE (PATTERN (next2)) == ADDR_VEC
! 			  || GET_CODE (PATTERN (next2)) == ADDR_DIFF_VEC))
! 		    {
! 		      delete_insn (insn);
! 		      insn = next2;
! 		    }
! 		  else
! 		    insn = delete_insn (insn);
! 		}
! 	      else if (GET_CODE (insn) == NOTE
  		  && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END)
  		insn = NEXT_INSN (insn);
  	      else
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.161.2.9
diff -c -3 -p -r1.161.2.9 varasm.c
*** varasm.c	2001/04/11 10:01:12	1.161.2.9
--- varasm.c	2001/04/28 16:24:30
*************** force_const_mem (mode, x)
*** 3594,3599 ****
--- 3594,3602 ----
        pool_offset += align - 1;
        pool_offset &= ~ (align - 1);
  
+       if (GET_CODE (x) == LABEL_REF)
+ 	LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
+ 
        /* Allocate a pool constant descriptor, fill it in, and chain it in.  
*/
  
        pool = (struct pool_constant *) ggc_alloc (sizeof (struct 
pool_constant));








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