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]

Re: [patch] Clear bb field for insns outside of basic blocks


> --- 4060,4066 ----
>   static void
>   extend_bb (void)
>   {
> !   rtx insn, note;
>
>     old_last_basic_block = last_basic_block;

Please move the declaration into the innermost scope.

> --- 4080,4088 ----
>   	  /* Don't emit a NOTE if it would end up before a BARRIER.  */
>   	  && !BARRIER_P (NEXT_INSN (insn))))
>       {
> !       note = emit_note_after (NOTE_INSN_DELETED, insn);
>         /* Make insn to appear outside BB.  */
> +       set_block_for_insn (note, NULL);
>         BB_END (EXIT_BLOCK_PTR->prev_bb) = insn;
>       }
>   }

Please remove the bogus "to" too.

> --- 630,636 ----
>   {
>     basic_block orig_bb = bb;
>     rtx insn = BB_HEAD (bb);
> !   rtx end = BB_END (bb), x;
>     rtx table;
>     rtx flow_transfer_insn = NULL_RTX;
>     edge fallthru = NULL;

Please move the declaration into the innermost scope.

> --- 651,666 ----
>   	{
>   	  fallthru = split_block (bb, PREV_INSN (insn));
>   	  if (flow_transfer_insn)
> ! 	    {
> ! 	      BB_END (bb) = flow_transfer_insn;
> !
> ! 	      /* Clean up the bb field for the insns between the blocks.  */
> ! 	      for (x = NEXT_INSN (flow_transfer_insn);
> ! 		   x != BB_HEAD (fallthru->dest);
> ! 		   x = NEXT_INSN (x))
> ! 		if (!BARRIER_P (x))
> ! 		  set_block_for_insn (x, NULL);
> ! 	    }

The loop looks overkill.  Don't you just have to check the following?

  if (NEXT_INSN (flow_transfer_insn) != BB_HEAD (fallthru->dest))

> *************** find_bb_boundaries (basic_block bb)
> *** 666,671 ****
> --- 675,688 ----
>   	{
>   	  fallthru = split_block (bb, PREV_INSN (insn));
>   	  BB_END (bb) = flow_transfer_insn;
> +
> + 	  /* Clean up the bb field for the insns between the blocks.  */
> + 	  for (x = NEXT_INSN (flow_transfer_insn);
> + 	       x != BB_HEAD (fallthru->dest);
> + 	       x = NEXT_INSN (x))
> + 	    if (!BARRIER_P (x))
> + 	      set_block_for_insn (x, NULL);
> +
>   	  bb = fallthru->dest;
>   	  remove_edge (fallthru);
>   	  flow_transfer_insn = NULL_RTX;

Likewise.

> --- 699,721 ----
>        return and barrier, or possibly other sequence not behaving like
>        ordinary jump, we need to take care and move basic block boundary. 
> */ if (flow_transfer_insn)
> !     {
> !       BB_END (bb) = flow_transfer_insn;
> !
> !       /* Clean up the bb field for the insns that do not belong to BB. 
> */ !       if (flow_transfer_insn != end)
> ! 	{
> ! 	  x = NEXT_INSN (flow_transfer_insn);
> ! 	  while (1)
> ! 	    {
> ! 	      if (!BARRIER_P (x))
> ! 		set_block_for_insn (x, NULL);
> ! 	      if (x == end)
> ! 		break;
> ! 	      x = NEXT_INSN (x);
> ! 	    }
> ! 	}
> !     }

  rtx x = flow_transfer_insn;
  while (x != end)
    {
      x = NEXT_INSN (x);
      if (!BARRIER_P (x))
        set_block_for_insn (x, NULL);
    }

> Index: rtl.h
> ===================================================================
> *** rtl.h	(revision 125276)
> --- rtl.h	(working copy)
> *************** extern rtx emit (rtx);
> *** 2062,2068 ****
>   extern rtx delete_insn (rtx);
>   extern rtx entry_of_function (void);
>   extern void emit_insn_at_entry (rtx);
> ! extern void delete_insn_chain (rtx, rtx);
>   extern rtx unlink_insn_chain (rtx, rtx);
>   extern rtx delete_insn_and_edges (rtx);
>   extern void delete_insn_chain_and_edges (rtx, rtx);
> --- 2062,2068 ----
>   extern rtx delete_insn (rtx);
>   extern rtx entry_of_function (void);
>   extern void emit_insn_at_entry (rtx);
> ! extern rtx delete_insn_chain (rtx, rtx);
>   extern rtx unlink_insn_chain (rtx, rtx);
>   extern rtx delete_insn_and_edges (rtx);
>   extern void delete_insn_chain_and_edges (rtx, rtx);

What about adding a third argument 'clear_bb' to delete_insn_chain instead?

> *************** rtl_verify_flow_info_1 (void)
> *** 1715,1720 ****
> --- 1741,1763 ----
>   		   bb->index);
>   	    err = 1;
>   	  }
> +
> +       for (insn = bb->il.rtl->header; insn; insn = NEXT_INSN (insn))
> + 	if (!BARRIER_P (insn)
> + 	    && BLOCK_FOR_INSN (insn) != NULL)
> + 	  {
> + 	    error ("insn %d in header of bb %d has non-NULL basic block",
> + 		   INSN_UID (insn), bb->index);
> + 	    err = 1;
> + 	  }
> +       for (insn = bb->il.rtl->footer; insn; insn = NEXT_INSN (insn))
> + 	if (!BARRIER_P (insn)
> + 	    && BLOCK_FOR_INSN (insn) != NULL)
> + 	  {
> + 	    error ("insn %d in footer of bb %d has non-NULL basic block",
> + 		   INSN_UID (insn), bb->index);
> + 	    err = 1;
> + 	  }
>       }
>
>     /* Now check the basic blocks (boundaries etc.) */
> *************** rtl_verify_flow_info (void)
> *** 1918,1927 ****
>         rtx head = BB_HEAD (bb);
>         rtx end = BB_END (bb);
>
> -       /* Verify the end of the basic block is in the INSN chain.  */
>         for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
> ! 	if (x == end)
> ! 	  break;
>
>         if (!x)
>   	{
> --- 1961,1981 ----
>         rtx head = BB_HEAD (bb);
>         rtx end = BB_END (bb);
>
>         for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
> ! 	{
> ! 	  /* Verify the end of the basic block is in the INSN chain.  */
> ! 	  if (x == end)
> ! 	    break;
> !
> ! 	  /* And that the code outside of basic blocks has NULL bb field.  */
> ! 	if (!BARRIER_P (x)
> ! 	    && BLOCK_FOR_INSN (x) != NULL)
> ! 	  {
> ! 	    error ("insn %d outside of basic blocks has non-NULL bb field",
> ! 		   INSN_UID (x));
> ! 	    err = 1;
> ! 	  }
> ! 	}
>
>         if (!x)
>   	{
> *************** rtl_verify_flow_info (void)
> *** 1955,1961 ****
>   	  err = 1;
>   	}
>
> !       last_head = x;
>
>         FOR_EACH_EDGE (e, ei, bb->succs)
>   	if (e->flags & EDGE_FALLTHRU)
> --- 2009,2015 ----
>   	  err = 1;
>   	}
>
> !       last_head = PREV_INSN (x);
>
>         FOR_EACH_EDGE (e, ei, bb->succs)
>   	if (e->flags & EDGE_FALLTHRU)
> *************** rtl_verify_flow_info (void)
> *** 2000,2005 ****
> --- 2054,2071 ----
>   	}
>       }
>
> +   for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
> +     {
> +       /* Check that the code before the first basic block has NULL
> + 	 bb field.  */
> +       if (!BARRIER_P (x)
> + 	  && BLOCK_FOR_INSN (x) != NULL)
> + 	{
> + 	  error ("insn %d outside of basic blocks has non-NULL bb field",
> + 		 INSN_UID (x));
> + 	  err = 1;
> + 	}
> +     }
>     free (bb_info);

Any particular reason for testing !BARRIER_P everywhere?

-- 
Eric Botcazou


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