aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@g5.osdl.org>2005-11-22 19:35:07 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-22 19:35:07 -0800
commit7e58336770b4102d1dac4b90a6a8310e3b81e18e (patch)
treebabb3ef0c4737e51538940ef9996c489e95e8ef1
parent3108192d73f1912cee8afdcd328d7eb1d724da64 (diff)
downloadsparse-dev-7e58336770b4102d1dac4b90a6a8310e3b81e18e.tar.gz
example: OP_COPY must destroy any old pseudo state
Toto, I have a feeling We're not in SSA land any more. (Not that it really helps. The example compiler not only had SSA assumptions, it also depended on liveness information and insn->def state, both of which are destroyed by the un-ssa phase. So this is really a small bandage around a much larger problem, and doesn't really fix anything fundamental). Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--example.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/example.c b/example.c
index f30c6afb..97d2fcbe 100644
--- a/example.c
+++ b/example.c
@@ -996,9 +996,33 @@ static void generate_load(struct instruction *insn, struct bb_state *state)
output_insn(state, "mov.%d %s,%s", insn->size, input, dst->name);
}
+static void kill_pseudo(struct bb_state *state, pseudo_t pseudo)
+{
+ int i;
+ struct hardreg *reg;
+
+ output_comment(state, "killing pseudo %s", show_pseudo(pseudo));
+ for (i = 0; i < REGNO; i++) {
+ pseudo_t p;
+
+ reg = hardregs + i;
+ FOR_EACH_PTR(reg->contains, p) {
+ if (p != pseudo)
+ continue;
+ if (CURRENT_TAG(p) & TAG_DEAD)
+ reg->dead--;
+ output_comment(state, "removing pseudo %s from reg %s",
+ show_pseudo(pseudo), reg->name);
+ DELETE_CURRENT_PTR(p);
+ } END_FOR_EACH_PTR(p);
+ PACK_PTR_LIST(&reg->contains);
+ }
+}
+
static void generate_copy(struct bb_state *state, struct instruction *insn)
{
struct hardreg *src = getreg(state, insn->src, insn->target);
+ kill_pseudo(state, insn->target);
add_pseudo_reg(state, insn->target, src);
}