OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / tree-phinodes.c
index 7fd5a8f..1d7e5c2 100644 (file)
@@ -1,5 +1,6 @@
 /* Generic routines for manipulating PHIs
-   Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -22,12 +23,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "rtl.h"
-#include "varray.h"
+#include "rtl.h"       /* FIXME: Only for ceil_log2, of all things...  */
 #include "ggc.h"
 #include "basic-block.h"
 #include "tree-flow.h"
-#include "toplev.h"
+#include "diagnostic-core.h"
 #include "gimple.h"
 
 /* Rewriting a function into SSA form can create a huge number of PHIs
@@ -154,7 +154,7 @@ allocate_phi_node (size_t len)
     }
   else
     {
-      phi = (gimple) ggc_alloc (size);
+      phi = ggc_alloc_gimple_statement_d (size);
 #ifdef GATHER_STATISTICS
       phi_nodes_created++;
        {
@@ -231,6 +231,8 @@ make_phi_node (tree var, int len)
   for (i = 0; i < capacity; i++)
     {
       use_operand_p  imm;
+
+      gimple_phi_arg_set_location (phi, i, UNKNOWN_LOCATION);
       imm = gimple_phi_arg_imm_use_ptr (phi, i);
       imm->use = gimple_phi_arg_def_ptr (phi, i);
       imm->prev = NULL;
@@ -299,6 +301,8 @@ resize_phi_node (gimple *phi, size_t len)
   for (i = gimple_phi_num_args (new_phi); i < len; i++)
     {
       use_operand_p imm;
+
+      gimple_phi_arg_set_location (new_phi, i, UNKNOWN_LOCATION);
       imm = gimple_phi_arg_imm_use_ptr (new_phi, i);
       imm->use = gimple_phi_arg_def_ptr (new_phi, i);
       imm->prev = NULL;
@@ -349,7 +353,7 @@ reserve_phi_args_for_new_edge (basic_block bb)
 
 /* Adds PHI to BB.  */
 
-void 
+void
 add_phi_node_to_bb (gimple phi, basic_block bb)
 {
   gimple_stmt_iterator gsi;
@@ -384,7 +388,7 @@ create_phi_node (tree var, basic_block bb)
    PHI points to the reallocated phi node when we return.  */
 
 void
-add_phi_arg (gimple phi, tree def, edge e)
+add_phi_arg (gimple phi, tree def, edge e, source_location locus)
 {
   basic_block bb = e->dest;
 
@@ -407,6 +411,7 @@ add_phi_arg (gimple phi, tree def, edge e)
     }
 
   SET_PHI_ARG_DEF (phi, e->dest_idx, def);
+  gimple_phi_arg_set_location (phi, e->dest_idx, locus);
 }
 
 
@@ -435,6 +440,9 @@ remove_phi_arg_num (gimple phi, int i)
       /* Set use on new node, and link into last element's place.  */
       *(new_p->use) = *(old_p->use);
       relink_imm_use (new_p, old_p);
+      /* Move the location as well.  */
+      gimple_phi_arg_set_location (phi, i,
+                                  gimple_phi_arg_location (phi, num_elem - 1));
     }
 
   /* Shrink the vector and return.  Note that we do not have to clear
@@ -465,6 +473,10 @@ void
 remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p)
 {
   gimple phi = gsi_stmt (*gsi);
+
+  if (release_lhs_p)
+    insert_debug_temps_for_defs (gsi);
+
   gsi_remove (gsi, false);
 
   /* If we are deleting the PHI node, then we should release the
@@ -474,4 +486,17 @@ remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p)
     release_ssa_name (gimple_phi_result (phi));
 }
 
+/* Remove all the phi nodes from BB.  */
+
+void
+remove_phi_nodes (basic_block bb)
+{
+  gimple_stmt_iterator gsi;
+
+  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
+    remove_phi_node (&gsi, true);
+
+  set_phi_nodes (bb, NULL);
+}
+
 #include "gt-tree-phinodes.h"