OSDN Git Service

* c-decl.c (c_init_decl_processing): Clear input_file_name
[pf3gnuchains/gcc-fork.git] / gcc / cfgcleanup.c
index 6ccc3ee..cfb838c 100644 (file)
@@ -656,12 +656,7 @@ label_is_jump_target_p (label, jump_insn)
   if (label == tmp)
     return true;
 
-  if (tmp != NULL_RTX
-      && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-      && GET_CODE (tmp) == JUMP_INSN
-      && (tmp = PATTERN (tmp),
-         GET_CODE (tmp) == ADDR_VEC
-         || GET_CODE (tmp) == ADDR_DIFF_VEC))
+  if (tablejump_p (jump_insn, NULL, &tmp))
     {
       rtvec vec = XVEC (tmp, GET_CODE (tmp) == ADDR_DIFF_VEC);
       int i, veclen = GET_NUM_ELEM (vec);
@@ -861,6 +856,8 @@ merge_blocks (e, b, c, mode)
       b_has_incoming_fallthru = (tmp_edge != NULL);
       b_fallthru_edge = tmp_edge;
       next = b->prev_bb;
+      if (next == c)
+       next = next->prev_bb;
 
       /* Otherwise, we're going to try to move C after B.  If C does
         not have an outgoing fallthru, then it can be moved
@@ -891,7 +888,7 @@ merge_blocks (e, b, c, mode)
       return next == ENTRY_BLOCK_PTR ? next->next_bb : next;
     }
 
-  return false;
+  return NULL;
 }
 \f
 
@@ -965,7 +962,15 @@ insns_match_p (mode, i1, i2)
 #endif
 
   if (reload_completed
-      ? ! rtx_renumbered_equal_p (p1, p2) : ! rtx_equal_p (p1, p2))
+      ? rtx_renumbered_equal_p (p1, p2) : rtx_equal_p (p1, p2))
+    return true;
+
+  /* Do not do EQUIV substitution after reload.  First, we're undoing the
+     work of reload_cse.  Second, we may be undoing the work of the post-
+     reload splitting pass.  */
+  /* ??? Possibly add a new phase switch variable that can be used by
+     targets to disallow the troublesome insns after splitting.  */
+  if (!reload_completed)
     {
       /* The following code helps take care of G++ cleanups.  */
       rtx equiv1 = find_reg_equal_equiv_note (i1);
@@ -992,11 +997,9 @@ insns_match_p (mode, i1, i2)
                return true;
            }
        }
-
-      return false;
     }
 
-  return true;
+  return false;
 }
 \f
 /* Look through the insns at the end of BB1 and BB2 and find the longest
@@ -1041,10 +1044,10 @@ flow_find_cross_jump (mode, bb1, bb2, f1, f2)
   while (true)
     {
       /* Ignore notes.  */
-      while (!active_insn_p (i1) && i1 != bb1->head)
+      while (!INSN_P (i1) && i1 != bb1->head)
        i1 = PREV_INSN (i1);
 
-      while (!active_insn_p (i2) && i2 != bb2->head)
+      while (!INSN_P (i2) && i2 != bb2->head)
        i2 = PREV_INSN (i2);
 
       if (i1 == bb1->head || i2 == bb2->head)
@@ -1053,8 +1056,8 @@ flow_find_cross_jump (mode, bb1, bb2, f1, f2)
       if (!insns_match_p (mode, i1, i2))
        break;
 
-      /* Don't begin a cross-jump with a USE or CLOBBER insn.  */
-      if (active_insn_p (i1))
+      /* Don't begin a cross-jump with a NOTE insn.  */
+      if (INSN_P (i1))
        {
          /* If the merged insns have different REG_EQUAL notes, then
             remove them.  */
@@ -1093,13 +1096,13 @@ flow_find_cross_jump (mode, bb1, bb2, f1, f2)
      Two, it keeps line number notes as matched as may be.  */
   if (ninsns)
     {
-      while (last1 != bb1->head && !active_insn_p (PREV_INSN (last1)))
+      while (last1 != bb1->head && !INSN_P (PREV_INSN (last1)))
        last1 = PREV_INSN (last1);
 
       if (last1 != bb1->head && GET_CODE (PREV_INSN (last1)) == CODE_LABEL)
        last1 = PREV_INSN (last1);
 
-      while (last2 != bb2->head && !active_insn_p (PREV_INSN (last2)))
+      while (last2 != bb2->head && !INSN_P (PREV_INSN (last2)))
        last2 = PREV_INSN (last2);
 
       if (last2 != bb2->head && GET_CODE (PREV_INSN (last2)) == CODE_LABEL)
@@ -1269,10 +1272,10 @@ outgoing_edges_match (mode, bb1, bb2)
             the jump tables are same too. So disable crossjumping of blocks BB1
             and BB2 because when deleting the common insns in the end of BB1
             by flow_delete_block () the jump table would be deleted too.  */
-         /* If LABEL2 is contained in BB1->END do not do anything
+         /* If LABEL2 is referenced in BB1->END do not do anything
             because we would loose information when replacing
             LABEL1 by LABEL2 and then LABEL2 by LABEL1 in BB1->END.  */
-         if (label1 != label2 && !subrtx_p (label2, bb1->end))
+         if (label1 != label2 && !rtx_referenced_p (label2, bb1->end))
            {
              /* Set IDENTICAL to true when the tables are identical.  */
              bool identical = false;
@@ -1299,13 +1302,14 @@ outgoing_edges_match (mode, bb1, bb2)
 
              if (identical)
                {
-                 rtx_pair rr;
+                 replace_label_data rr;
                  bool match;
 
                  /* Temporarily replace references to LABEL1 with LABEL2
                     in BB1->END so that we could compare the instructions.  */
                  rr.r1 = label1;
                  rr.r2 = label2;
+                 rr.update_label_nuses = false;
                  for_each_rtx (&bb1->end, replace_label, &rr);
 
                  match = insns_match_p (mode, bb1->end, bb2->end);
@@ -1457,12 +1461,13 @@ try_crossjump_to_edge (mode, e1, e2)
          && tablejump_p (src2->end, &label2, &table2)
          && label1 != label2)
        {
-         rtx_pair rr;
+         replace_label_data rr;
          rtx insn;
 
          /* Replace references to LABEL1 with LABEL2.  */
          rr.r1 = label1;
          rr.r2 = label2;
+         rr.update_label_nuses = true;
          for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
            {
              /* Do not replace the label in SRC1->END because when deleting
@@ -1474,7 +1479,7 @@ try_crossjump_to_edge (mode, e1, e2)
        }
     }
 #endif
-  
+
   /* Avoid splitting if possible.  */
   if (newpos2 == src2->head)
     redirect_to = src2;
@@ -1781,7 +1786,9 @@ try_optimize_cfg (mode)
                  /* If the jump insn has side effects,
                     we can't kill the edge.  */
                  && (GET_CODE (b->end) != JUMP_INSN
-                     || simplejump_p (b->end))
+                     || (flow2_completed
+                         ? simplejump_p (b->end)
+                         : onlyjump_p (b->end)))
                  && (next = merge_blocks (s, b, c, mode)))
                {
                  b = next;