diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-31 23:45:35 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:02:29 -0700 |
| commit | 289b1a3f9638956b95ae715362bb1c839412d28b (patch) | |
| tree | be064eb8d89e2f4d2a0c2ee6837889e89ce0a65b | |
| parent | c7dd9904334069605f9108160083c68f89731fcf (diff) | |
| download | sparse-dev-289b1a3f9638956b95ae715362bb1c839412d28b.tar.gz | |
Simplify the trivial direct "indirect" goto.
Goto's of the form "goto *&&label" might actually end up
happening as part of constant folding. And even if they
don't, this is the RightThing(tm) to do.
| -rw-r--r-- | linearize.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/linearize.c b/linearize.c index bc402322..bbeef884 100644 --- a/linearize.c +++ b/linearize.c @@ -828,6 +828,7 @@ pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stmt) case STMT_GOTO: { struct symbol *sym; + struct expression *expr; struct instruction *goto_ins; pseudo_t pseudo; @@ -836,7 +837,14 @@ pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stmt) break; } - pseudo = linearize_expression(ep, stmt->goto_expression); + /* This can happen as part of simplification */ + expr = stmt->goto_expression; + if (expr->type == EXPR_LABEL) { + add_goto(ep, get_bound_block(ep, expr->label_symbol)); + break; + } + + pseudo = linearize_expression(ep, expr); goto_ins = alloc_instruction(OP_COMPUTEDGOTO, NULL); add_one_insn(ep, stmt->pos, goto_ins); goto_ins->target = pseudo; |
