[PATCH 5/5] symaddr: keep OP_SYMADDR instructions

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

 



OP_SYMADDR instructions are systematically eliminated during
simplification phase, their target address being simply replaced
by the symbol itself.

While at first sight, it doesn't look wrong per se (as it all
depends to the semantic we want to give to pseudos and the
instructions and how high- or low-level we want the IR to be),
it's not clear if this simplification was really intentional
and don't seems to have any advantages.

A deeper look show that it is a problem to remove OP_SYMADDRS
as they presence inhibit memops simplification that would
otherwise be illegal. The only places we're it is correct to
replace the result of an OP_SYMADDR by the symbol itself is
for the address of OP_LOAD or OP_STORE because the addressability
is handled directely for these instructions.

Change this by removing the 'simplification' of OP_SYMADDR.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                          | 2 +-
 validation/call-inlined.c           | 6 ++++--
 validation/call-variadic.c          | 3 ++-
 validation/linear/degen-array.c     | 9 ++++++---
 validation/mem2reg/address-used00.c | 1 -
 validation/symaddr-op.c             | 1 -
 validation/symaddr.c                | 9 ++++++---
 7 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/simplify.c b/simplify.c
index b3cd76e3d..1593fed79 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1207,7 +1207,7 @@ int simplify_instruction(struct instruction *insn)
 	case OP_SYMADDR:
 		if (dead_insn(insn, NULL, NULL, NULL))
 			return REPEAT_CSE | REPEAT_SYMBOL_CLEANUP;
-		return replace_with_pseudo(insn, insn->symbol);
+		return 0;
 	case OP_CAST:
 	case OP_SCAST:
 	case OP_FPCAST:
diff --git a/validation/call-inlined.c b/validation/call-inlined.c
index b907ded60..a5b8b89e5 100644
--- a/validation/call-inlined.c
+++ b/validation/call-inlined.c
@@ -39,14 +39,16 @@ bar:
 bas:
 .L6:
 	<entry-point>
-	add.64      %r16 <- "abc", $1
+	symaddr.64  %r14 <- "abc"
+	add.64      %r16 <- %r14, $1
 	ret.64      %r16
 
 
 qus:
 .L9:
 	<entry-point>
-	add.64      %r21 <- messg, $1
+	symaddr.64  %r19 <- messg
+	add.64      %r21 <- %r19, $1
 	ret.64      %r21
 
 
diff --git a/validation/call-variadic.c b/validation/call-variadic.c
index 8c9815621..7f62eb191 100644
--- a/validation/call-variadic.c
+++ b/validation/call-variadic.c
@@ -15,7 +15,8 @@ int foo(const char *fmt, int a, long l, int *p)
 foo:
 .L0:
 	<entry-point>
-	call.32     %r5 <- print, "msg %c: %d %d/%ld %ld/%p %p\n", $120, %arg2, $7, %arg3, $0, %arg4, $0
+	symaddr.64  %r1 <- "msg %c: %d %d/%ld %ld/%p %p\n"
+	call.32     %r5 <- print, %r1, $120, %arg2, $7, %arg3, $0, %arg4, $0
 	ret.32      %r5
 
 
diff --git a/validation/linear/degen-array.c b/validation/linear/degen-array.c
index b8a6f4f66..a8a267633 100644
--- a/validation/linear/degen-array.c
+++ b/validation/linear/degen-array.c
@@ -12,19 +12,22 @@ int *fd(int i) { return  a; }
 fa:
 .L0:
 	<entry-point>
-	ret.64      a
+	symaddr.64  %r1 <- a
+	ret.64      %r1
 
 
 f0:
 .L2:
 	<entry-point>
-	ret.64      a
+	symaddr.64  %r3 <- a
+	ret.64      %r3
 
 
 fd:
 .L4:
 	<entry-point>
-	ret.64      a
+	symaddr.64  %r6 <- a
+	ret.64      %r6
 
 
  * check-output-end
diff --git a/validation/mem2reg/address-used00.c b/validation/mem2reg/address-used00.c
index a41f05c25..e9198ee7b 100644
--- a/validation/mem2reg/address-used00.c
+++ b/validation/mem2reg/address-used00.c
@@ -13,7 +13,6 @@ int foo(int **g, int j)
 /*
  * check-name: address-used00
  * check-command: test-linearize -Wno-decl -fdump-ir=final $file
- * check-known-to-fail
  * check-output-ignore
  * check-output-excludes: ret\\..* \\$1
  * check-output-contains: ret\\..* \\$0
diff --git a/validation/symaddr-op.c b/validation/symaddr-op.c
index c17c328f8..8a836fb36 100644
--- a/validation/symaddr-op.c
+++ b/validation/symaddr-op.c
@@ -11,7 +11,6 @@ char foo(int *ptr, long i)
 /*
  * check-name: symaddr-op
  * check-command: test-linearize -m64 -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: add.64 .* <- s,
diff --git a/validation/symaddr.c b/validation/symaddr.c
index 97f640f91..4fe776c21 100644
--- a/validation/symaddr.c
+++ b/validation/symaddr.c
@@ -21,9 +21,12 @@ int foo(void)
 foo:
 .L0:
 	<entry-point>
-	call        usep, g
-	call        usep, a
-	add.64      %r4 <- b, $4
+	symaddr.64  %r1 <- g
+	call        usep, %r1
+	symaddr.64  %r2 <- a
+	call        usep, %r2
+	symaddr.64  %r3 <- b
+	add.64      %r4 <- %r3, $4
 	call        usep, %r4
 	ret.32      $0
 
-- 
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