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]

Fix -fprofile-use on Perl


Hi,
perl is currently failing to compile with FDO because it does use longjmp.  It
is bit lame, but we represent functions returning twice via fake edges to EXIT
block that have negative counts.  This makes the new consistency checking to
accept it.  Also new code output just simple inconsistency message that makes
it difficult to debug.  I've added dumping code.

Will commit it after bootstrap/regtest (that will quite likely pass ;))
	* profile.c (is_edge_inconsistent): Add debug output; ignore negative count
	on fake edges.
	(is_inconsistent): Add debug output.
Index: profile.c
===================================================================
*** profile.c	(revision 139985)
--- profile.c	(working copy)
*************** is_edge_inconsistent (VEC(edge,gc) *edge
*** 277,284 ****
      {
        if (!EDGE_INFO (e)->ignore)
          {
!           if (e->count < 0)
!             return true;
          }
      }
    return false;
--- 277,296 ----
      {
        if (!EDGE_INFO (e)->ignore)
          {
!           if (e->count < 0
! 	      && ((!e->flags & EDGE_FAKE)
! 	          || !block_ends_with_call_p (e->src)))
! 	    {
! 	      if (dump_file)
! 		{
! 		  fprintf (dump_file,
! 		  	   "Edge %i->%i is inconsistent, count"HOST_WIDEST_INT_PRINT_DEC,
! 			   e->src->index, e->dest->index, e->count);
! 		  dump_bb (e->src, dump_file, 0);
! 		  dump_bb (e->dest, dump_file, 0);
! 		}
!               return true;
! 	    }
          }
      }
    return false;
*************** static bool
*** 307,326 ****
  is_inconsistent (void)
  {
    basic_block bb;
    FOR_EACH_BB (bb)
      {
!       if (is_edge_inconsistent (bb->preds))
!         return true;
!       if (is_edge_inconsistent (bb->succs))
!         return true;
!       if ( bb->count != sum_edge_counts (bb->preds)
!          || (bb->count != sum_edge_counts (bb->succs) &&
!              !(find_edge (bb, EXIT_BLOCK_PTR) != NULL &&
!                block_ends_with_call_p (bb))))
!         return true;
      }
  
!   return false;
  }
  
  /* Set each basic block count to the sum of its outgoing edge counts */
--- 319,377 ----
  is_inconsistent (void)
  {
    basic_block bb;
+   bool inconsistent = false;
    FOR_EACH_BB (bb)
      {
!       inconsistent |= is_edge_inconsistent (bb->preds);
!       if (!dump_file && inconsistent)
! 	return true;
!       inconsistent |= is_edge_inconsistent (bb->succs);
!       if (!dump_file && inconsistent)
! 	return true;
!       if (bb->count < 0)
!         {
! 	  if (dump_file)
! 	    {
! 	      fprintf (dump_file, "BB %i count is negative "
! 		       HOST_WIDEST_INT_PRINT_DEC,
! 		       bb->index,
! 		       bb->count);
! 	      dump_bb (bb, dump_file, 0);
! 	    }
! 	  inconsistent = true;
! 	}
!       if (bb->count != sum_edge_counts (bb->preds))
!         {
! 	  if (dump_file)
! 	    {
! 	      fprintf (dump_file, "BB %i count does not match sum of incomming edges "
! 		       HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
! 		       bb->index,
! 		       bb->count,
! 		       sum_edge_counts (bb->preds));
! 	      dump_bb (bb, dump_file, 0);
! 	    }
! 	  inconsistent = true;
! 	}
!       if (bb->count != sum_edge_counts (bb->succs) &&
!           ! (find_edge (bb, EXIT_BLOCK_PTR) != NULL && block_ends_with_call_p (bb)))
! 	{
! 	  if (dump_file)
! 	    {
! 	      fprintf (dump_file, "BB %i count does not match sum of outgoing edges "
! 		       HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
! 		       bb->index,
! 		       bb->count,
! 		       sum_edge_counts (bb->succs));
! 	      dump_bb (bb, dump_file, 0);
! 	    }
! 	  inconsistent = true;
! 	}
!       if (!dump_file && inconsistent)
! 	return true;
      }
  
!   return inconsistent;
  }
  
  /* Set each basic block count to the sum of its outgoing edge counts */


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