summaryrefslogtreecommitdiff
path: root/gcc/cfg.c
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-22 15:42:25 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-22 15:42:25 +0000
commit59948e03783081644e2adb6bd2bea62303f57ed8 (patch)
treed3f550f669389b94a6ae1c48cf11123e7ac1e744 /gcc/cfg.c
parent2d5e9bd761df15e11c77300d91683e5f78be45ac (diff)
downloadgcc-59948e03783081644e2adb6bd2bea62303f57ed8.tar.gz
* cfg.c (cached_make_edge): Call make_edge if edge cache is
not available. Use tail calls wherever possible. (make_edge): Call unchecked_make_edge to create an edge. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95396 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r--gcc/cfg.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c
index bc68faab799..6737003e60c 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -273,43 +273,29 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags)
edge
cached_make_edge (sbitmap *edge_cache, basic_block src, basic_block dst, int flags)
{
- int use_edge_cache;
- edge e;
-
- /* Don't bother with edge cache for ENTRY or EXIT, if there aren't that
- many edges to them, or we didn't allocate memory for it. */
- use_edge_cache = (edge_cache
- && src != ENTRY_BLOCK_PTR && dst != EXIT_BLOCK_PTR);
+ if (edge_cache == NULL
+ || src == ENTRY_BLOCK_PTR
+ || dst == EXIT_BLOCK_PTR)
+ return make_edge (src, dst, flags);
- /* Make sure we don't add duplicate edges. */
- switch (use_edge_cache)
+ /* Does the requested edge already exist? */
+ if (! TEST_BIT (edge_cache[src->index], dst->index))
{
- default:
- /* Quick test for non-existence of the edge. */
- if (! TEST_BIT (edge_cache[src->index], dst->index))
- break;
-
- /* The edge exists; early exit if no work to do. */
- if (flags == 0)
- return NULL;
-
- /* Fall through. */
- case 0:
- e = find_edge (src, dst);
- if (e)
- {
- e->flags |= flags;
- return NULL;
- }
- break;
+ /* The edge does not exist. Create one and update the
+ cache. */
+ SET_BIT (edge_cache[src->index], dst->index);
+ return unchecked_make_edge (src, dst, flags);
}
- e = unchecked_make_edge (src, dst, flags);
-
- if (use_edge_cache)
- SET_BIT (edge_cache[src->index], dst->index);
+ /* At this point, we know that the requested edge exists. Adjust
+ flags if necessary. */
+ if (flags)
+ {
+ edge e = find_edge (src, dst);
+ e->flags |= flags;
+ }
- return e;
+ return NULL;
}
/* Create an edge connecting SRC and DEST with flags FLAGS. Return newly
@@ -318,7 +304,16 @@ cached_make_edge (sbitmap *edge_cache, basic_block src, basic_block dst, int fla
edge
make_edge (basic_block src, basic_block dest, int flags)
{
- return cached_make_edge (NULL, src, dest, flags);
+ edge e = find_edge (src, dest);
+
+ /* Make sure we don't add duplicate edges. */
+ if (e)
+ {
+ e->flags |= flags;
+ return NULL;
+ }
+
+ return unchecked_make_edge (src, dest, flags);
}
/* Create an edge connecting SRC to DEST and set probability by knowing