From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 5/5] IR: let OP_COMPUTEGOTO use .src instead of .target
Date: Wed, 14 Feb 2018 02:08:43 +0100 [thread overview]
Message-ID: <20180214010843.23651-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20180214010843.23651-1-luc.vanoostenryck@gmail.com>
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>
---
Documentation/IR.md | 2 +-
linearize.c | 4 ++--
liveness.c | 5 +----
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/Documentation/IR.md b/Documentation/IR.md
index 8f5827dfc..ef486ed5a 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 0fa12c36f..370c6c7d7 100644
--- a/linearize.c
+++ b/linearize.c
@@ -399,7 +399,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);
@@ -2120,7 +2120,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) {
diff --git a/liveness.c b/liveness.c
index 0c525112b..568e2d5f2 100644
--- a/liveness.c
+++ b/liveness.c
@@ -53,6 +53,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction *
switch (insn->opcode) {
case OP_RET:
+ case OP_COMPUTEDGOTO:
USES(src);
break;
@@ -61,10 +62,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:
--
2.16.0
prev parent reply other threads:[~2018-02-14 1:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 1:08 [PATCH 0/5] IR cleanup Luc Van Oostenryck
2018-02-14 1:08 ` [PATCH 1/5] IR: fix typo in IR doc Luc Van Oostenryck
2018-02-14 1:08 ` [PATCH 2/5] IR: remove now unused OP_LNOP & OP_SNOP Luc Van Oostenryck
2018-02-14 1:08 ` [PATCH 3/5] IR: remove never-generated instructions Luc Van Oostenryck
2018-02-14 5:08 ` Dibyendu Majumdar
2018-02-14 21:48 ` Luc Van Oostenryck
2018-02-14 1:08 ` [PATCH 4/5] IR: let .cond unionize with .src and not .target Luc Van Oostenryck
2018-02-14 1:08 ` Luc Van Oostenryck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180214010843.23651-6-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).