diff options
Diffstat (limited to 'gcc/tree-phinodes.c')
-rw-r--r-- | gcc/tree-phinodes.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index dcf4ba078ab..963ef0a9578 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -206,7 +206,7 @@ static tree make_phi_node (tree var, int len) { tree phi; - int capacity; + int capacity, i; capacity = ideal_phi_node_len (len); @@ -226,6 +226,15 @@ make_phi_node (tree var, int len) else SET_PHI_RESULT (phi, make_ssa_name (var, phi)); + for (i = 0; i < capacity; i++) + { + ssa_imm_use_t * imm; + imm = &(PHI_ARG_IMM_USE_NODE (phi, i)); + imm->use = &(PHI_ARG_DEF_TREE (phi, i)); + imm->prev = NULL; + imm->next = NULL; + imm->stmt = phi; + } return phi; } @@ -236,6 +245,14 @@ release_phi_node (tree phi) { int bucket; int len = PHI_ARG_CAPACITY (phi); + int x; + + for (x = 0; x < PHI_NUM_ARGS (phi); x++) + { + ssa_imm_use_t * imm; + imm = &(PHI_ARG_IMM_USE_NODE (phi, x)); + delink_imm_use (imm); + } bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len; bucket -= 2; @@ -250,7 +267,7 @@ release_phi_node (tree phi) static void resize_phi_node (tree *phi, int len) { - int old_size; + int old_size, i; tree new_phi; gcc_assert (len > PHI_ARG_CAPACITY (*phi)); @@ -265,8 +282,28 @@ resize_phi_node (tree *phi, int len) memcpy (new_phi, *phi, old_size); + for (i = 0; i < PHI_NUM_ARGS (new_phi); i++) + { + ssa_imm_use_t *imm, *old_imm; + imm = &(PHI_ARG_IMM_USE_NODE (new_phi, i)); + old_imm = &(PHI_ARG_IMM_USE_NODE (*phi, i)); + imm->use = &(PHI_ARG_DEF_TREE (new_phi, i)); + relink_imm_use_stmt (imm, old_imm, new_phi); + } + PHI_ARG_CAPACITY (new_phi) = len; + for (i = PHI_NUM_ARGS (new_phi); i < len; i++) + { + ssa_imm_use_t * imm; + imm = &(PHI_ARG_IMM_USE_NODE (new_phi, i)); + imm->use = &(PHI_ARG_DEF_TREE (new_phi, i)); + imm->prev = NULL; + imm->next = NULL; + imm->stmt = new_phi; + } + + *phi = new_phi; } @@ -372,6 +409,9 @@ remove_phi_arg_num (tree phi, int i) gcc_assert (i < num_elem); + /* Delink the last item, which is being removed. */ + delink_imm_use (&(PHI_ARG_IMM_USE_NODE (phi, num_elem - 1))); + /* If we are not at the last element, switch the last element with the element we want to delete. */ if (i != num_elem - 1) @@ -423,8 +463,8 @@ remove_phi_node (tree phi, tree prev) /* If we are deleting the PHI node, then we should release the SSA_NAME node so that it can be reused. */ - release_ssa_name (PHI_RESULT (phi)); release_phi_node (phi); + release_ssa_name (PHI_RESULT (phi)); } @@ -461,8 +501,8 @@ remove_all_phi_nodes_for (bitmap vars) { /* If we are deleting the PHI node, then we should release the SSA_NAME node so that it can be reused. */ - release_ssa_name (PHI_RESULT (phi)); release_phi_node (phi); + release_ssa_name (PHI_RESULT (phi)); } } |