OSDN Git Service

* typeck.c (comptypes): First determine if the types are compatible
[pf3gnuchains/gcc-fork.git] / gcc / value-prof.c
index 1663e64..c3a70f9 100644 (file)
@@ -1,5 +1,5 @@
 /* Transformations based on profile information for values.
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -245,7 +245,8 @@ insn_prefetch_values_to_profile (rtx insn, histogram_values *values)
   int write;
   histogram_value hist;
 
-  if (!INSN_P (insn))
+  /* It only makes sense to look for memory references in ordinary insns.  */
+  if (GET_CODE (insn) != INSN)
     return false;
 
   if (!find_mem_reference (insn, &mem, &write))
@@ -288,13 +289,30 @@ static void
 rtl_find_values_to_profile (histogram_values *values)
 {
   rtx insn;
-  unsigned i;
+  unsigned i, libcall_level;
 
   life_analysis (NULL, PROP_DEATH_NOTES);
 
   *values = VEC_alloc (histogram_value, 0);
+  libcall_level = 0;
   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
-    insn_values_to_profile (insn, values);
+    {
+      if (find_reg_note (insn, REG_LIBCALL, NULL_RTX))
+       libcall_level++;
+
+      /* Do not instrument values inside libcalls (we are going to split block
+        due to instrumentation, and libcall blocks should be local to a single
+        basic block).  */
+      if (!libcall_level)
+       insn_values_to_profile (insn, values);
+
+      if (find_reg_note (insn, REG_RETVAL, NULL_RTX))
+       {
+         gcc_assert (libcall_level > 0);
+         libcall_level--;
+       }
+    }
+  gcc_assert (libcall_level == 0);
 
   for (i = 0; i < VEC_length (histogram_value, *values); i++)
     {
@@ -342,7 +360,7 @@ rtl_find_values_to_profile (histogram_values *values)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
   allocate_reg_info (max_reg_num (), FALSE, FALSE);
@@ -808,7 +826,7 @@ gen_mod_subtract (enum machine_mode mode, enum rtx_code operation,
 static bool
 mod_subtract_transform (rtx insn)
 {
-  rtx set, set_src, set_dest, op1, op2, value, histogram;
+  rtx set, set_src, set_dest, op1, op2, histogram;
   enum rtx_code code;
   enum machine_mode mode;
   gcov_type wrong_values, counts[2], count, all;
@@ -840,7 +858,6 @@ mod_subtract_transform (rtx insn)
     return false;
 
   histogram = XEXP (XEXP (histogram, 0), 1);
-  value = XEXP (histogram, 0);
   histogram = XEXP (histogram, 1);
 
   all = 0;
@@ -1014,21 +1031,20 @@ void
 rtl_register_value_prof_hooks (void)
 {
   value_prof_hooks = &rtl_value_prof_hooks;
-  if (ir_type ())
-    abort ();
+  gcc_assert (!ir_type ());
 }
 \f
 /* Tree-based versions are stubs for now.  */
 static void
 tree_find_values_to_profile (histogram_values *values ATTRIBUTE_UNUSED)
 {
-  abort ();
+  gcc_unreachable ();
 }
 
 static bool
 tree_value_profile_transformations (void)
 {
-  abort ();
+  gcc_unreachable ();
 }
 
 static struct value_prof_hooks tree_value_prof_hooks = {
@@ -1040,8 +1056,7 @@ void
 tree_register_value_prof_hooks (void)
 {
   value_prof_hooks = &tree_value_prof_hooks;
-  if (!ir_type ())
-    abort ();
+  gcc_assert (ir_type ());
 }
 \f
 /* IR-independent entry points.  */