aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linearize.c
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-02-22 11:51:37 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:01:25 -0700
commita323e6d3b412a01f6243f1459c556dea0a88e318 (patch)
tree39540a7b07746e0b6c6ce3601b28ecd06fe035e2 /linearize.c
parent77323e6f59a229c296a1c6e431979325287dfab1 (diff)
downloadsparse-dev-a323e6d3b412a01f6243f1459c556dea0a88e318.tar.gz
Make a difference between an anonymous label and a
named one. For an anonymous one, we can just re-use an existing named one if we're at the same point.
Diffstat (limited to 'linearize.c')
-rw-r--r--linearize.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/linearize.c b/linearize.c
index 8e947afb..e86cb799 100644
--- a/linearize.c
+++ b/linearize.c
@@ -93,6 +93,24 @@ static void add_label(struct entrypoint *ep, struct symbol *sym)
ep->active = new_bb;
}
+/*
+ * Add a anonymous label, return the symbol for it..
+ *
+ * If we already have a label for the top of the active
+ * context, we can just re-use it.
+ */
+static struct symbol *create_label(struct entrypoint *ep, struct position pos)
+{
+ struct basic_block *bb = ep->active;
+ struct symbol *label = bb->this;
+
+ if (!bb_reachable(bb) || !ptr_list_empty(bb->stmts)) {
+ label = alloc_symbol(pos, SYM_LABEL);
+ add_label(ep, label);
+ }
+ return label;
+}
+
static void linearize_simple_statement(struct entrypoint *ep, struct statement *stmt)
{
struct basic_block *bb = ep->active;
@@ -200,9 +218,7 @@ void linearize_statement(struct entrypoint *ep, struct statement *stmt)
* with the fallthrough of the never case.
*/
if (bb_reachable(ep->active)) {
- struct symbol *merge = alloc_symbol(never->pos, SYM_LABEL);
- add_label(ep, merge);
- bb->next = merge;
+ bb->next = create_label(ep, never->pos);
break;
}
@@ -284,10 +300,8 @@ void linearize_statement(struct entrypoint *ep, struct statement *stmt)
}
}
- if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) {
- loop_top = alloc_symbol(stmt->pos, SYM_LABEL);
- add_label(ep, loop_top);
- }
+ if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value)
+ loop_top = create_label(ep, stmt->pos);
linearize_statement(ep, statement);