diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-20 17:33:15 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-01 09:07:45 +0100 |
| commit | e207d0df64d8086d059349bc08fee310cf1cba84 (patch) | |
| tree | 194b3d5ce8d4fa8c5d952ad3f1b52912c062e0ba | |
| parent | 39c697538115e7c402ab890f6d8755b2c1ddf826 (diff) | |
| download | sparse-dev-e207d0df64d8086d059349bc08fee310cf1cba84.tar.gz | |
IR: let OP_COMPUTEGOTO use .src instead of .target
In struct instruction, .target is normally used to hold
the result. Its value is thus produced/defined by instructions.
However, OP_COMPUTEDGOTO use .target as an input. This
creates slight complications for code, like liveness analysis,
which care about which fields are used and which are defined
by the instructions.
Change this by letting OP_COMPUTEDGOTO use .src for its
operand instead of .target.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | Documentation/IR.md | 2 | ||||
| -rw-r--r-- | linearize.c | 4 | ||||
| -rw-r--r-- | liveness.c | 5 |
3 files changed, 4 insertions, 7 deletions
diff --git a/Documentation/IR.md b/Documentation/IR.md index 7bbeda8f..03fa3f80 100644 --- a/Documentation/IR.md +++ b/Documentation/IR.md @@ -39,7 +39,7 @@ Switch / multi-branch #### OP_COMPUTEDGOTO Computed goto / branch to register -- .target: target address (type is irrelevant, void*) +- .src: address to branch to (void*) - .multijmp_list: list of possible destination basic blocks ### Arithmetic binops diff --git a/linearize.c b/linearize.c index eaa8913b..58da7ceb 100644 --- a/linearize.c +++ b/linearize.c @@ -390,7 +390,7 @@ const char *show_instruction(struct instruction *insn) } case OP_COMPUTEDGOTO: { struct multijmp *jmp; - buf += sprintf(buf, "%s", show_pseudo(insn->target)); + buf += sprintf(buf, "%s", show_pseudo(insn->src)); FOR_EACH_PTR(insn->multijmp_list, jmp) { buf += sprintf(buf, ", .L%u", jmp->target->nr); } END_FOR_EACH_PTR(jmp); @@ -2100,7 +2100,7 @@ static pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stm pseudo = linearize_expression(ep, expr); goto_ins = alloc_instruction(OP_COMPUTEDGOTO, 0); - use_pseudo(goto_ins, pseudo, &goto_ins->target); + use_pseudo(goto_ins, pseudo, &goto_ins->src); add_one_insn(ep, goto_ins); FOR_EACH_PTR(stmt->target_list, sym) { @@ -54,6 +54,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * switch (insn->opcode) { case OP_RET: + case OP_COMPUTEDGOTO: USES(src); break; @@ -62,10 +63,6 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction * USES(cond); break; - case OP_COMPUTEDGOTO: - USES(target); - break; - /* Binary */ case OP_BINARY ... OP_BINARY_END: case OP_FPCMP ... OP_FPCMP_END: |
