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]

[3.3/mainline] Fix PR/10239


Hello,

the problem in PR/10239 is that we were deleting following instruction
but we decreased LABEL_NUSES only for label 19, but not for label 43,
which was the label for jumptable.
(the tablejump is being replaced by simple jump because put_web is inlined to
reset_lists and we know that TYPE == INITIAL)

(insn/v 41 40 65 1 0x4017c3c8 (set (reg:HI 34)
        (const:HI (truncate:HI (minus:SI (label_ref:SI 19)
                    (label_ref:SI 43))))) 32 {*m68k.md:1018} (nil)
    (insn_list:REG_LABEL 19 (insn_list:REG_LABEL 43 (expr_list:REG_EQUAL (const:HI (truncate:HI (minus:SI (label_ref:SI 19)
                            (label_ref:SI 43))))
                (nil)))))

The LABEL_NUSES for jumptable remained positive so the jumptable was not
removed and GCC generated references to undefined labels.

This patch fixes it.

Bootstrapped/regtested x86-64.

OK for 3.3 branch and mainline?

Josef

2003-10-03  Josef Zlomek  <zlomekj@suse.cz>

	* cfgrtl.c (delete_insn): Decrease LABEL_NUSES for all REG_LABEL notes.

Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/gcc/cfgrtl.c,v
retrieving revision 1.61.2.12
diff -c -3 -p -r1.61.2.12 cfgrtl.c
*** cfgrtl.c	17 Sep 2003 07:17:08 -0000	1.61.2.12
--- cfgrtl.c	3 Oct 2003 13:15:41 -0000
*************** delete_insn (insn)
*** 148,156 ****
      LABEL_NUSES (JUMP_LABEL (insn))--;
  
    /* Also if deleting an insn that references a label.  */
!   else if ((note = find_reg_note (insn, REG_LABEL, NULL_RTX)) != NULL_RTX
! 	   && GET_CODE (XEXP (note, 0)) == CODE_LABEL)
!     LABEL_NUSES (XEXP (note, 0))--;
  
    if (GET_CODE (insn) == JUMP_INSN
        && (GET_CODE (PATTERN (insn)) == ADDR_VEC
--- 148,162 ----
      LABEL_NUSES (JUMP_LABEL (insn))--;
  
    /* Also if deleting an insn that references a label.  */
!   else
!     {
!       while ((note = find_reg_note (insn, REG_LABEL, NULL_RTX)) != NULL_RTX
! 	     && GET_CODE (XEXP (note, 0)) == CODE_LABEL)
! 	{
! 	  LABEL_NUSES (XEXP (note, 0))--;
! 	  remove_note (insn, note);
! 	}
!     }
  
    if (GET_CODE (insn) == JUMP_INSN
        && (GET_CODE (PATTERN (insn)) == ADDR_VEC

============== testcase =======================
/* Testcase must be compiled for m68k-unknown-linux-gnu with -O */
enum node_type
{
  INITIAL = 0, FREE,
  PRECOLORED,
  SIMPLIFY, SIMPLIFY_SPILL, SIMPLIFY_FAT, FREEZE, SPILL,
  SELECT,
  SPILLED, COALESCED, COLORED,
  LAST_NODE_TYPE
};

inline void
put_web (enum node_type type)
{
  switch (type)
    {
      case INITIAL:
      case FREE:
      case FREEZE:
      case SPILL:
	foo();
	break;
      case PRECOLORED:
	bar();
	break;
      default:
	baz ();
    }
}

void
reset_lists ()
{
  put_web (INITIAL);
}
============================


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