diff options
author | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-20 05:02:28 +0000 |
---|---|---|
committer | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-20 05:02:28 +0000 |
commit | 532f6ac12898fe43f5e2f172bd72a5a14c4c00cc (patch) | |
tree | adcd8f1cb11423dfef36a3d69e2b7f39b0f21c01 /gcc/cfg.c | |
parent | ad1a4db8a51c4e0e5db999b99bc6cfd83a1e955c (diff) | |
download | gcc-532f6ac12898fe43f5e2f172bd72a5a14c4c00cc.tar.gz |
* basic-block.h (edge_def): Add dest_idx.
* cfg.c (unchecked_make_edge): Initialize dest_idx.
(remove_edge): Simplify the disconnection of an edge from its
destination.
(redirect_edge_succ): Likewise.
* cfghooks.c (verify_flow_info): Check the consistency of
dest_idx for each edge.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90958 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r-- | gcc/cfg.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c index b3da1429b1d..67b0598341f 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -276,6 +276,7 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags) e->src = src; e->dest = dst; e->flags = flags; + e->dest_idx = EDGE_COUNT (dst->preds) - 1; return e; } @@ -355,11 +356,13 @@ remove_edge (edge e) { edge tmp; basic_block src, dest; + unsigned int dest_idx; bool found = false; edge_iterator ei; src = e->src; dest = e->dest; + dest_idx = e->dest_idx; for (ei = ei_start (src->succs); (tmp = ei_safe_edge (ei)); ) { @@ -375,20 +378,12 @@ remove_edge (edge e) gcc_assert (found); - found = false; - for (ei = ei_start (dest->preds); (tmp = ei_safe_edge (ei)); ) - { - if (tmp == e) - { - VEC_unordered_remove (edge, dest->preds, ei.index); - found = true; - break; - } - else - ei_next (&ei); - } + VEC_unordered_remove (edge, dest->preds, dest_idx); - gcc_assert (found); + /* If we removed an edge in the middle of the edge vector, we need + to update dest_idx of the edge that moved into the "hole". */ + if (dest_idx < EDGE_COUNT (dest->preds)) + EDGE_PRED (dest, dest_idx)->dest_idx = dest_idx; free_edge (e); } @@ -398,28 +393,20 @@ remove_edge (edge e) void redirect_edge_succ (edge e, basic_block new_succ) { - edge tmp; - edge_iterator ei; - bool found = false; + basic_block dest = e->dest; + unsigned int dest_idx = e->dest_idx; - /* Disconnect the edge from the old successor block. */ - for (ei = ei_start (e->dest->preds); (tmp = ei_safe_edge (ei)); ) - { - if (tmp == e) - { - VEC_unordered_remove (edge, e->dest->preds, ei.index); - found = true; - break; - } - else - ei_next (&ei); - } + VEC_unordered_remove (edge, dest->preds, dest_idx); - gcc_assert (found); + /* If we removed an edge in the middle of the edge vector, we need + to update dest_idx of the edge that moved into the "hole". */ + if (dest_idx < EDGE_COUNT (dest->preds)) + EDGE_PRED (dest, dest_idx)->dest_idx = dest_idx; /* Reconnect the edge to the new successor block. */ VEC_safe_push (edge, new_succ->preds, e); e->dest = new_succ; + e->dest_idx = EDGE_COUNT (new_succ->preds) - 1; } /* Like previous but avoid possible duplicate edge. */ |