Patchwork Fix PR56131 - Don't reorder DELETED_LABEL and BASIC_BLOCK notes without CFG

login
register
mail settings
Submitter Tom de Vries
Date Feb. 25, 2013, 11:31 a.m.
Message ID <512B4B7B.7090907@mentor.com>
Download mbox | patch
Permalink /patch/222910/
State New
Headers show

Comments

Tom de Vries - Feb. 25, 2013, 11:31 a.m.
Jakub,

attached patch fixes (or rather, fixes up the previous fix for) PR56131.

The patch makes sure that we don't try to reorder DELETED_LABEL and BASIC_BLOCK
NOTE_INSNs when there is no CFG.

The patch will prevent PR56242 from triggering on hppa,

In addition, the patch adds a comment in insn-notes.def about when
NOTE_INSN_BASIC_BLOCK cannot be expected to be reliable.

Bootstrapped and reg-tested on x86_64.

OK for trunk?

Thanks,
- Tom

2013-02-25  Tom de Vries  <tom@codesourcery.com>

	PR rtl-optimization/56131
	* insn-notes.def (INSN_NOTE_BASIC_BLOCK): Update comment.
	* cfgrtl.c (delete_insn): Don't reorder NOTE_INSN_DELETED_LABEL and
	NOTE_INSN_BASIC_BLOCK if BLOCK_FOR_INSN == NULL.
Jakub Jelinek - Feb. 25, 2013, 11:47 a.m.
On Mon, Feb 25, 2013 at 12:31:07PM +0100, Tom de Vries wrote:
> OK for trunk?
> 
> Thanks,
> - Tom
> 
> 2013-02-25  Tom de Vries  <tom@codesourcery.com>
> 
> 	PR rtl-optimization/56131
> 	* insn-notes.def (INSN_NOTE_BASIC_BLOCK): Update comment.
> 	* cfgrtl.c (delete_insn): Don't reorder NOTE_INSN_DELETED_LABEL and
> 	NOTE_INSN_BASIC_BLOCK if BLOCK_FOR_INSN == NULL.

Ok, thanks.

	Jakub

Patch

Index: gcc/insn-notes.def
===================================================================
--- gcc/insn-notes.def (revision 195874)
+++ gcc/insn-notes.def (working copy)
@@ -70,7 +70,9 @@  INSN_NOTE (CALL_ARG_LOCATION)
 
 /* Record the struct for the following basic block.  Uses
    NOTE_BASIC_BLOCK.  FIXME: Redundant with the basic block pointer
-   now included in every insn.  */
+   now included in every insn.  NOTE: If there's no CFG anymore, in other words,
+   if BLOCK_FOR_INSN () == NULL, NOTE_BASIC_BLOCK cannot be considered reliable
+   anymore.  */
 INSN_NOTE (BASIC_BLOCK)
 
 /* Mark the inflection point in the instruction stream where we switch
Index: gcc/cfgrtl.c
===================================================================
--- gcc/cfgrtl.c (revision 195874)
+++ gcc/cfgrtl.c (working copy)
@@ -135,7 +135,7 @@  delete_insn (rtx insn)
       if (! can_delete_label_p (insn))
 	{
 	  const char *name = LABEL_NAME (insn);
-	  basic_block bb, label_bb = BLOCK_FOR_INSN (insn);
+	  basic_block bb = BLOCK_FOR_INSN (insn);
 	  rtx bb_note = NEXT_INSN (insn);
 
 	  really_delete = false;
@@ -144,15 +144,13 @@  delete_insn (rtx insn)
 	  NOTE_DELETED_LABEL_NAME (insn) = name;
 
 	  /* If the note following the label starts a basic block, and the
-	     label is a member of the same basic block, interchange the two.
-	     If the label is not marked with a bb, assume it's the same bb.  */
+	     label is a member of the same basic block, interchange the two.  */
 	  if (bb_note != NULL_RTX
 	      && NOTE_INSN_BASIC_BLOCK_P (bb_note)
-	      && (label_bb == NOTE_BASIC_BLOCK (bb_note)
-		  || label_bb == NULL))
+	      && bb != NULL
+	      && bb == BLOCK_FOR_INSN (bb_note))
 	    {
 	      reorder_insns_nobb (insn, insn, bb_note);
-	      bb = NOTE_BASIC_BLOCK (bb_note);
 	      BB_HEAD (bb) = bb_note;
 	      if (BB_END (bb) == bb_note)
 		BB_END (bb) = insn;