diff options
author | 2007-01-16 18:36:16 -0800 | |
---|---|---|
committer | 2007-01-16 20:47:04 -0800 | |
commit | e7fb6e092055425e404052bfc9ffefd38365c009 (patch) | |
tree | 7c1cd6c88d690be4332440898bd9865fbb5f5abc /memops.c | |
parent | Change the symbol access list to a pseudo list (diff) | |
download | sparse-e7fb6e092055425e404052bfc9ffefd38365c009.tar.gz sparse-e7fb6e092055425e404052bfc9ffefd38365c009.tar.bz2 sparse-e7fb6e092055425e404052bfc9ffefd38365c009.zip |
Add instruction to pseudo user tracking.
The current way of tracking pseudo register user is by
keeping a list of the address of the pseudo_t member.
This address can be in part of the instruction member, the
worse case is in the argument list of the call instruction.
As the comment for address_taken() said, using the container
to get instruction pointer is wrong. It use to work with instruction
that relate to symbol address. But that is not true any more. Even
worse, it is very hard to track the pseudo usage other than symbol
address. The only reason symbol address used to works for call instruction
is because call instruction did not directly use the symbol address.
I bit the bullet and just add the instruction pointer to pair with
the pseudo user pointer. So it will work with the case that the
user instruction is call as well.
Testing:
I compare the linearize result with/without the patch on a few
sparse source file it self. The linearize generate exactly
the same result except the symbol address changes. Which is
predictable different because the pseudo user structure allocate
memory.
Singed-Off-By: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'memops.c')
-rw-r--r-- | memops.c | 22 |
1 files changed, 5 insertions, 17 deletions
@@ -59,31 +59,19 @@ found_dominator: phi = alloc_phi(parent, one->target, one->size); phi->ident = phi->ident ? : one->target->ident; add_instruction(&parent->insns, br); - use_pseudo(phi, add_pseudo(dominators, phi)); + use_pseudo(insn, phi, add_pseudo(dominators, phi)); } END_FOR_EACH_PTR(parent); return 1; } -/* - * FIXME! This is wrong. Since we now distribute out the OP_SYMADDR, - * we can no longer really use "container()" to get from a user to - * the instruction that uses it. - * - * This happens to work, simply because the likelihood of the - * (possibly non-instruction) containing the right bitpattern - * in the right place is pretty low. But this is still wrong. - * - * We should make symbol-pseudos count non-load/store usage, - * or something. - */ static int address_taken(pseudo_t pseudo) { - pseudo_t *usep; - FOR_EACH_PTR(pseudo->users, usep) { - struct instruction *insn = container(usep, struct instruction, src); + struct pseudo_user *pu; + FOR_EACH_PTR(pseudo->users, pu) { + struct instruction *insn = pu->insn; if (insn->bb && (insn->opcode != OP_LOAD || insn->opcode != OP_STORE)) return 1; - } END_FOR_EACH_PTR(usep); + } END_FOR_EACH_PTR(pu); return 0; } |