[PATCH 4/5] symaddr: fold them into loads & stores

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Memory simplification can and effectively do a more precise
job when more information is known about the memop's address.
For example, it knows that two distinct symbol won't alias
while, of course, nothing similar can be said if the address
are mere pointers to some unknown objects.
In other words, we prefer to see:
	load.32         %r2, 0[s]
than:
	symaddr.32	%r1, s
	load.32         %r2, 0[%r1]

So, to insure that memop use the symbol when possible,
for each memop using the result of an OP_SYMADDR as
address, replace the address by the symbol itself.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/simplify.c b/simplify.c
index a2edda479..b3cd76e3d 100644
--- a/simplify.c
+++ b/simplify.c
@@ -901,6 +901,16 @@ static int simplify_memop(struct instruction *insn)
 	int one, ret = 0;
 	pseudo_t orig = insn->src;
 
+	// try to fold symbol address into the access
+	if (orig->type == PSEUDO_REG) {
+		struct instruction *def = orig->def;
+		if (def->opcode == OP_SYMADDR) {
+			pseudo_t sym = def->symbol;
+			kill_use(&insn->src);
+			use_pseudo(insn, sym, &insn->src);
+		}
+	}
+
 	do {
 		one = simplify_one_memop(insn, orig);
 		ret |= one;
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux