@@ -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:
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,
@@ -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
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@gmail.com> --- 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(-)