preofile.c versus setjmp

Jan Hubicka jh@suse.cz
Tue Aug 7 04:33:00 GMT 2001


Hi
This patch adds fake entry edge for setjmp, so the code handles it correctly.
It is depedent on the next patch, as it uses the REG_SETJMP, instead of
NOTE_INSN_SETJMP, but I would love to see it in, with the trivial case, even
in case the next patch gets blocked.

Honza


Po srp  6 22:06:51 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* profile.c (branch_prob): Add fake edges for setjmp.

*** profile.c.setjmp	Mon Aug  6 21:20:02 2001
--- profile.c	Mon Aug  6 21:38:59 2001
*************** branch_prob ()
*** 547,552 ****
--- 547,579 ----
        basic_block bb = BASIC_BLOCK (i);
        edge e;
  
+       /* Add fake edges from entry block to the call insns that may return
+ 	 twice.  The CFG is not quite correct then, as call insn plays more
+ 	 role of CODE_LABEL, but for our purposes, everything should be OK,
+ 	 as we never insert code to the beggining of basic block.  */
+       for (insn = bb->head; insn != NEXT_INSN (bb->end); insn = NEXT_INSN (insn))
+ 	{
+ 	  if (GET_CODE (insn) == CALL_INSN
+ 	      && find_reg_note (insn, REG_SETJMP, NULL))
+ 	    {
+ 	      if (GET_CODE (bb->head) == CODE_LABEL
+ 		  || insn != NEXT_INSN (bb->head))
+ 		{
+ 		  e = split_block (bb, PREV_INSN (insn));
+ 		  make_edge (NULL, ENTRY_BLOCK_PTR, e->dest, EDGE_FAKE);
+ 		  break;
+ 		}
+ 	      else
+ 		{
+ 		  /* We should not get abort here, as call to setjmp should not
+ 		     be the very first instruction of function.  */
+ 		  if (!i)
+ 		    abort ();
+ 		  make_edge (NULL, ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
+ 		}
+ 	    }
+ 	}
+ 
        for (e = bb->succ; e; e = e->succ_next)
  	{
  	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))



More information about the Gcc-patches mailing list