OSDN Git Service

* gcc.dg/20020201-1.c: Use cleanup-coverage_files.
[pf3gnuchains/gcc-fork.git] / gcc / tree-cfg.c
index c9a8e31..b1ff8e6 100644 (file)
@@ -457,9 +457,9 @@ fold_cond_expr_cond (void)
        {
          tree cond = fold (COND_EXPR_COND (stmt));
          if (integer_zerop (cond))
-           COND_EXPR_COND (stmt) = integer_zero_node;
+           COND_EXPR_COND (stmt) = boolean_false_node;
          else if (integer_onep (cond))
-           COND_EXPR_COND (stmt) = integer_one_node;
+           COND_EXPR_COND (stmt) = boolean_true_node;
        }
     }
 }
@@ -837,7 +837,7 @@ label_to_block (tree dest)
 static void
 make_goto_expr_edges (basic_block bb)
 {
-  tree goto_t, dest;
+  tree goto_t;
   basic_block target_bb;
   int for_call;
   block_stmt_iterator last = bsi_last (bb);
@@ -848,13 +848,10 @@ make_goto_expr_edges (basic_block bb)
      CALL_EXPR or MODIFY_EXPR), then the edge is an abnormal edge resulting
      from a nonlocal goto.  */
   if (TREE_CODE (goto_t) != GOTO_EXPR)
-    {
-      dest = error_mark_node;
-      for_call = 1;
-    }
+    for_call = 1;
   else
     {
-      dest = GOTO_DESTINATION (goto_t);
+      tree dest = GOTO_DESTINATION (goto_t);
       for_call = 0;
 
       /* A GOTO to a local label creates normal edges.  */
@@ -1192,7 +1189,7 @@ group_case_labels (void)
           i = 0;
          while (i < old_size - 1)
            {
-             tree base_case, base_label, base_high, type;
+             tree base_case, base_label, base_high;
              base_case = TREE_VEC_ELT (labels, i);
 
              gcc_assert (base_case);
@@ -1208,7 +1205,6 @@ group_case_labels (void)
                  continue;
                }
 
-             type = TREE_TYPE (CASE_LOW (base_case));
              base_high = CASE_HIGH (base_case) ?
                CASE_HIGH (base_case) : CASE_LOW (base_case);
              i++;
@@ -1260,16 +1256,16 @@ tree_can_merge_blocks_p (basic_block a, basic_block b)
   tree stmt;
   block_stmt_iterator bsi;
 
-  if (EDGE_COUNT (a->succs) != 1)
+  if (!single_succ_p (a))
     return false;
 
-  if (EDGE_SUCC (a, 0)->flags & EDGE_ABNORMAL)
+  if (single_succ_edge (a)->flags & EDGE_ABNORMAL)
     return false;
 
-  if (EDGE_SUCC (a, 0)->dest != b)
+  if (single_succ (a) != b)
     return false;
 
-  if (EDGE_COUNT (b->preds) > 1)
+  if (!single_pred_p (b))
     return false;
 
   if (b == EXIT_BLOCK_PTR)
@@ -1324,7 +1320,7 @@ tree_merge_blocks (basic_block a, basic_block b)
   /* Ensure that B follows A.  */
   move_block_after (b, a);
 
-  gcc_assert (EDGE_SUCC (a, 0)->flags & EDGE_FALLTHRU);
+  gcc_assert (single_succ_edge (a)->flags & EDGE_FALLTHRU);
   gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)));
 
   /* Remove labels from B and set bb_for_stmt to A for other statements.  */
@@ -1922,16 +1918,17 @@ cfg_remove_useless_stmts_bb (basic_block bb)
 
   /* Check whether we come here from a condition, and if so, get the
      condition.  */
-  if (EDGE_COUNT (bb->preds) != 1
-      || !(EDGE_PRED (bb, 0)->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+  if (!single_pred_p (bb)
+      || !(single_pred_edge (bb)->flags
+          & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
     return;
 
-  cond = COND_EXPR_COND (last_stmt (EDGE_PRED (bb, 0)->src));
+  cond = COND_EXPR_COND (last_stmt (single_pred (bb)));
 
   if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL)
     {
       var = cond;
-      val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
+      val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE
             ? boolean_false_node : boolean_true_node);
     }
   else if (TREE_CODE (cond) == TRUTH_NOT_EXPR
@@ -1939,12 +1936,12 @@ cfg_remove_useless_stmts_bb (basic_block bb)
               || TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL))
     {
       var = TREE_OPERAND (cond, 0);
-      val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
+      val = (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE
             ? boolean_true_node : boolean_false_node);
     }
   else
     {
-      if (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE)
+      if (single_pred_edge (bb)->flags & EDGE_FALSE_VALUE)
        cond = invert_truthvalue (cond);
       if (TREE_CODE (cond) == EQ_EXPR
          && (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
@@ -2208,10 +2205,10 @@ cleanup_control_flow (void)
              else
                {
                  /* Turn off the EDGE_ABNORMAL flag.  */
-                 EDGE_SUCC (bb, 0)->flags &= ~EDGE_ABNORMAL;
+                 e->flags &= ~EDGE_ABNORMAL;
 
                  /* And set EDGE_FALLTHRU.  */
-                 EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
+                 e->flags |= EDGE_FALLTHRU;
                  ei_next (&ei);
                }
            }
@@ -2249,7 +2246,7 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
   bool retval = false;
   tree expr = bsi_stmt (bsi), val;
 
-  if (EDGE_COUNT (bb->succs) > 1)
+  if (!single_succ_p (bb))
     {
       edge e;
       edge_iterator ei;
@@ -2291,7 +2288,7 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
        taken_edge->probability = REG_BR_PROB_BASE;
     }
   else
-    taken_edge = EDGE_SUCC (bb, 0);
+    taken_edge = single_succ_edge (bb);
 
   bsi_remove (&bsi);
   taken_edge->flags = EDGE_FALLTHRU;
@@ -2379,20 +2376,11 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
   edge true_edge, false_edge;
 
   extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
-
-  /* Otherwise, try to determine which branch of the if() will be taken.
-     If VAL is a constant but it can't be reduced to a 0 or a 1, then
-     we don't really know which edge will be taken at runtime.  This
-     may happen when comparing addresses (e.g., if (&var1 == 4)).  */
-  if (integer_nonzerop (val))
-    return true_edge;
-  else if (integer_zerop (val))
-    return false_edge;
-
-  gcc_unreachable ();
+  
+  gcc_assert (TREE_CODE (val) == INTEGER_CST);
+  return (zero_p (val) ? false_edge : true_edge);
 }
 
-
 /* Given an INTEGER_CST VAL and the entry block BB to a SWITCH_EXPR
    statement, determine which edge will be taken out of the block.  Return
    NULL if any edge may be taken.  */
@@ -2862,14 +2850,14 @@ disband_implicit_edges (void)
        {
          /* Remove the RETURN_EXPR if we may fall though to the exit
             instead.  */
-         gcc_assert (EDGE_COUNT (bb->succs) == 1);
-         gcc_assert (EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR);
+         gcc_assert (single_succ_p (bb));
+         gcc_assert (single_succ (bb) == EXIT_BLOCK_PTR);
 
          if (bb->next_bb == EXIT_BLOCK_PTR
              && !TREE_OPERAND (stmt, 0))
            {
              bsi_remove (&last);
-             EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
+             single_succ_edge (bb)->flags |= EDGE_FALLTHRU;
            }
          continue;
        }
@@ -3164,7 +3152,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
      would have to examine the PHIs to prove that none of them used
      the value set by the statement we want to insert on E.  That
      hardly seems worth the effort.  */
-  if (EDGE_COUNT (dest->preds) == 1
+  if (single_pred_p (dest)
       && ! phi_nodes (dest)
       && dest != EXIT_BLOCK_PTR)
     {
@@ -3196,7 +3184,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
      Except for the entry block.  */
   src = e->src;
   if ((e->flags & EDGE_ABNORMAL) == 0
-      && EDGE_COUNT (src->succs) == 1
+      && single_succ_p (src)
       && src != ENTRY_BLOCK_PTR)
     {
       *bsi = bsi_last (src);
@@ -3227,7 +3215,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
   dest = split_edge (e);
   if (new_bb)
     *new_bb = dest;
-  e = EDGE_PRED (dest, 0);
+  e = single_pred_edge (dest);
   goto restart;
 }
 
@@ -3242,7 +3230,7 @@ bsi_commit_edge_inserts (void)
   edge e;
   edge_iterator ei;
 
-  bsi_commit_one_edge_insert (EDGE_SUCC (ENTRY_BLOCK_PTR, 0), NULL);
+  bsi_commit_one_edge_insert (single_succ_edge (ENTRY_BLOCK_PTR), NULL);
 
   FOR_EACH_BB (bb)
     FOR_EACH_EDGE (e, ei, bb->succs)
@@ -3699,6 +3687,12 @@ verify_stmts (void)
        {
          int phi_num_args = PHI_NUM_ARGS (phi);
 
+         if (bb_for_stmt (phi) != bb)
+           {
+             error ("bb_for_stmt (phi) is set to a wrong basic block\n");
+             err |= true;
+           }
+
          for (i = 0; i < phi_num_args; i++)
            {
              tree t = PHI_ARG_DEF (phi, i);
@@ -3737,6 +3731,13 @@ verify_stmts (void)
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); )
        {
          tree stmt = bsi_stmt (bsi);
+
+         if (bb_for_stmt (stmt) != bb)
+           {
+             error ("bb_for_stmt (stmt) is set to a wrong basic block\n");
+             err |= true;
+           }
+
          bsi_next (&bsi);
          err |= verify_stmt (stmt, bsi_end_p (bsi));
          addr = walk_tree (&stmt, verify_node_sharing, htab, NULL);
@@ -3940,14 +3941,15 @@ tree_verify_flow_info (void)
          break;
 
        case RETURN_EXPR:
-         if (EDGE_COUNT (bb->succs) != 1
-             || (EDGE_SUCC (bb, 0)->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
-                                    | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+         if (!single_succ_p (bb)
+             || (single_succ_edge (bb)->flags
+                 & (EDGE_FALLTHRU | EDGE_ABNORMAL
+                    | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
            {
              error ("Wrong outgoing edge flags at end of bb %d\n", bb->index);
              err = 1;
            }
-         if (EDGE_SUCC (bb, 0)->dest != EXIT_BLOCK_PTR)
+         if (single_succ (bb) != EXIT_BLOCK_PTR)
            {
              error ("Return edge does not point to exit in bb %d\n",
                     bb->index);
@@ -4064,7 +4066,7 @@ tree_make_forwarder_block (edge fallthru)
   dummy = fallthru->src;
   bb = fallthru->dest;
 
-  if (EDGE_COUNT (bb->preds) == 1)
+  if (single_pred_p (bb))
     return;
 
   /* If we redirected a branch we must create new phi nodes at the
@@ -4105,16 +4107,16 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
   block_stmt_iterator bsi;
 
   /* BB must have a single outgoing edge.  */
-  if (EDGE_COUNT (bb->succs) != 1
+  if (single_succ_p (bb) != 1
       /* If PHI_WANTED is false, BB must not have any PHI nodes.
         Otherwise, BB must have PHI nodes.  */
       || (phi_nodes (bb) != NULL_TREE) != phi_wanted
       /* BB may not be a predecessor of EXIT_BLOCK_PTR.  */
-      || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+      || single_succ (bb) == EXIT_BLOCK_PTR
       /* Nor should this be an infinite loop.  */
-      || EDGE_SUCC (bb, 0)->dest == bb
+      || single_succ (bb) == bb
       /* BB may not have an abnormal outgoing edge.  */
-      || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL))
+      || (single_succ_edge (bb)->flags & EDGE_ABNORMAL))
     return false; 
 
 #if ENABLE_CHECKING
@@ -4179,7 +4181,7 @@ has_abnormal_incoming_edge_p (basic_block bb)
 static bool
 remove_forwarder_block (basic_block bb, basic_block **worklist)
 {
-  edge succ = EDGE_SUCC (bb, 0), e, s;
+  edge succ = single_succ_edge (bb), e, s;
   basic_block dest = succ->dest;
   tree label;
   tree phi;
@@ -4338,7 +4340,7 @@ cleanup_forwarder_blocks (void)
 static void
 remove_forwarder_block_with_phi (basic_block bb)
 {
-  edge succ = EDGE_SUCC (bb, 0);
+  edge succ = single_succ_edge (bb);
   basic_block dest = succ->dest;
   tree label;
   basic_block dombb, domdest, dom;
@@ -4379,7 +4381,7 @@ remove_forwarder_block_with_phi (basic_block bb)
          /* PHI arguments are different.  Create a forwarder block by
             splitting E so that we can merge PHI arguments on E to
             DEST.  */
-         e = EDGE_SUCC (split_edge (e), 0);
+         e = single_succ_edge (split_edge (e));
        }
 
       s = redirect_edge_and_branch (e, dest);
@@ -4481,7 +4483,7 @@ merge_phi_nodes (void)
       if (!tree_forwarder_block_p (bb, true))
        continue;
 
-      dest = EDGE_SUCC (bb, 0)->dest;
+      dest = single_succ (bb);
 
       /* We have to feed into another basic block with PHI
         nodes.  */