aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorIlya Tocar <ilya.tocar@intel.com>2015-04-06 12:37:34 +0300
committerIlya Tocar <ilya.tocar@intel.com>2015-04-06 12:37:34 +0300
commit1fa29f10602cd0ab395e0f83c9d87ab160b0df8a (patch)
treeacd7f929971240760aa1a3723d1a64734f2218be /gold/testsuite
parentcbaa2d709747b9da2955761ec86cbee4340263e3 (diff)
downloadgdb-1fa29f10602cd0ab395e0f83c9d87ab160b0df8a.zip
gdb-1fa29f10602cd0ab395e0f83c9d87ab160b0df8a.tar.gz
gdb-1fa29f10602cd0ab395e0f83c9d87ab160b0df8a.tar.bz2
[Gold,x86_64] Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %reg
2015-04-06 Ilya Tocar <ilya.tocar@intel.com> PR gold/17641 * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): New. (Target_x86_64::Scan::local): Don't create GOT entry, when we can convert mov to lea. (Target_x86_64::Scan::global): Ditto. (Target_x86_64::Relocate::relocate): Convert mov foo@GOTPCREL(%rip), %reg to lea foo(%rip), %reg if possible. * testsuite/Makefile.am (x86_64_mov_to_lea): New test. * testsuite/x86_64_mov_to_lea1.s: New. * testsuite/x86_64_mov_to_lea2.s: Ditto. * testsuite/x86_64_mov_to_lea3.s: Ditto. * testsuite/x86_64_mov_to_lea4.s: Ditto. * testsuite/x86_64_mov_to_lea.sh: Ditto. ---
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am91
-rwxr-xr-xgold/testsuite/x86_64_mov_to_lea.sh42
-rw-r--r--gold/testsuite/x86_64_mov_to_lea1.s11
-rw-r--r--gold/testsuite/x86_64_mov_to_lea2.s6
-rw-r--r--gold/testsuite/x86_64_mov_to_lea3.s10
-rw-r--r--gold/testsuite/x86_64_mov_to_lea4.s12
6 files changed, 172 insertions, 0 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index d64547e..1ffeb50 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -962,6 +962,97 @@ endif FN_PTRS_IN_SO_WITHOUT_PIC
endif TLS
+if DEFAULT_TARGET_X86_64
+
+check_SCRIPTS += x86_64_mov_to_lea.sh
+check_DATA += x86_64_mov_to_lea1.stdout x86_64_mov_to_lea2.stdout \
+ x86_64_mov_to_lea3.stdout x86_64_mov_to_lea4.stdout \
+ x86_64_mov_to_lea5.stdout x86_64_mov_to_lea6.stdout \
+ x86_64_mov_to_lea7.stdout x86_64_mov_to_lea8.stdout \
+ x86_64_mov_to_lea9.stdout x86_64_mov_to_lea10.stdout \
+ x86_64_mov_to_lea11.stdout x86_64_mov_to_lea12.stdout \
+ x86_64_mov_to_lea13.stdout x86_64_mov_to_lea14.stdout
+MOSTLYCLEANFILES += x86_64_mov_to_lea1 x86_64_mov_to_lea2 \
+ x86_64_mov_to_lea3 x86_64_mov_to_lea4 x86_64_mov_to_lea5 \
+ x86_64_mov_to_lea6 x86_64_mov_to_lea7 x86_64_mov_to_lea8 \
+ x86_64_mov_to_lea9 x86_64_mov_to_lea10 x86_64_mov_to_lea11 \
+ x86_64_mov_to_lea12 x86_64_mov_to_lea13 x86_64_mov_to_lea14
+
+x86_64_mov_to_lea1.o: x86_64_mov_to_lea1.s
+ $(TEST_AS) --64 -o $@ $<
+x86_64_mov_to_lea2.o: x86_64_mov_to_lea1.s
+ $(TEST_AS) --x32 -o $@ $<
+x86_64_mov_to_lea3.o: x86_64_mov_to_lea2.s
+ $(TEST_AS) --x32 -o $@ $<
+x86_64_mov_to_lea4.o: x86_64_mov_to_lea2.s
+ $(TEST_AS) --64 -o $@ $<
+x86_64_mov_to_lea5.o: x86_64_mov_to_lea3.s
+ $(TEST_AS) --x32 -o $@ $<
+x86_64_mov_to_lea6.o: x86_64_mov_to_lea3.s
+ $(TEST_AS) --64 -o $@ $<
+x86_64_mov_to_lea7.o: x86_64_mov_to_lea4.s
+ $(TEST_AS) --x32 -o $@ $<
+x86_64_mov_to_lea8.o: x86_64_mov_to_lea4.s
+ $(TEST_AS) --64 -o $@ $<
+x86_64_mov_to_lea1: x86_64_mov_to_lea1.o
+ ../ld-new -Bsymbolic -shared -melf_x86_64 -o $@ $<
+x86_64_mov_to_lea2: x86_64_mov_to_lea1.o
+ ../ld-new -pie -melf_x86_64 -o $@ $<
+x86_64_mov_to_lea3: x86_64_mov_to_lea1.o
+ ../ld-new -melf_x86_64 -o $@ $<
+x86_64_mov_to_lea4: x86_64_mov_to_lea2.o
+ ../ld-new -Bsymbolic -shared -melf32_x86_64 -o $@ $<
+x86_64_mov_to_lea5: x86_64_mov_to_lea2.o
+ ../ld-new -pie -melf32_x86_64 -o $@ $<
+x86_64_mov_to_lea6: x86_64_mov_to_lea2.o
+ ../ld-new -melf32_x86_64 -o $@ $<
+x86_64_mov_to_lea7: x86_64_mov_to_lea3.o
+ ../ld-new -melf32_x86_64 -pie -o $@ $<
+x86_64_mov_to_lea8: x86_64_mov_to_lea4.o
+ ../ld-new -melf_x86_64 -pie -o $@ $<
+x86_64_mov_to_lea9: x86_64_mov_to_lea5.o
+ ../ld-new -melf32_x86_64 -o $@ $<
+x86_64_mov_to_lea10: x86_64_mov_to_lea6.o
+ ../ld-new -melf_x86_64 -o $@ $<
+x86_64_mov_to_lea11: x86_64_mov_to_lea1.o
+ ../ld-new -melf32_x86_64 -shared -o $@ $<
+x86_64_mov_to_lea12: x86_64_mov_to_lea2.o
+ ../ld-new -melf_x86_64 -shared -o $@ $<
+x86_64_mov_to_lea13: x86_64_mov_to_lea7.o
+ ../ld-new -melf32_x86_64 -shared -o $@ $<
+x86_64_mov_to_lea14: x86_64_mov_to_lea8.o
+ ../ld-new -melf_x86_64 -shared -o $@ $<
+x86_64_mov_to_lea1.stdout: x86_64_mov_to_lea1
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea2.stdout: x86_64_mov_to_lea2
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea3.stdout: x86_64_mov_to_lea3
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea4.stdout: x86_64_mov_to_lea4
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea5.stdout: x86_64_mov_to_lea5
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea6.stdout: x86_64_mov_to_lea6
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea7.stdout: x86_64_mov_to_lea7
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea8.stdout: x86_64_mov_to_lea8
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea9.stdout: x86_64_mov_to_lea9
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea10.stdout: x86_64_mov_to_lea10
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea11.stdout: x86_64_mov_to_lea11
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea12.stdout: x86_64_mov_to_lea12
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea13.stdout: x86_64_mov_to_lea13
+ $(TEST_OBJDUMP) -dw $< > $@
+x86_64_mov_to_lea14.stdout: x86_64_mov_to_lea14
+ $(TEST_OBJDUMP) -dw $< > $@
+
+endif DEFAULT_TARGET_X86_64
+
if DEFAULT_TARGET_I386
check_SCRIPTS += i386_mov_to_lea.sh
diff --git a/gold/testsuite/x86_64_mov_to_lea.sh b/gold/testsuite/x86_64_mov_to_lea.sh
new file mode 100755
index 0000000..ee24a41
--- /dev/null
+++ b/gold/testsuite/x86_64_mov_to_lea.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# x86_64_mov_to_lea.sh -- a test for mov2lea conversion.
+
+# Copyright (C) 2010-2015 Free Software Foundation, Inc.
+# Written by Tocar Ilya <ilya.tocar@intel.com>
+
+# This file is part of gold.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+set -e
+
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea1.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea2.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea3.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea4.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea5.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea6.stdout
+grep -q "mov 0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea7.stdout
+grep -q "mov 0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea8.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea9.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea10.stdout
+grep -q "mov 0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea11.stdout
+grep -q "mov 0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea12.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea13.stdout
+grep -q "lea -0x[a-f0-9]\+(%rip),%rax" x86_64_mov_to_lea14.stdout
+
+exit 0
diff --git a/gold/testsuite/x86_64_mov_to_lea1.s b/gold/testsuite/x86_64_mov_to_lea1.s
new file mode 100644
index 0000000..4dce487
--- /dev/null
+++ b/gold/testsuite/x86_64_mov_to_lea1.s
@@ -0,0 +1,11 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl _start
+ .type _start, @function
+_start:
+ movq foo@GOTPCREL(%rip), %rax
+ .size _start, .-_start
diff --git a/gold/testsuite/x86_64_mov_to_lea2.s b/gold/testsuite/x86_64_mov_to_lea2.s
new file mode 100644
index 0000000..2a11b7a
--- /dev/null
+++ b/gold/testsuite/x86_64_mov_to_lea2.s
@@ -0,0 +1,6 @@
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ movq _DYNAMIC@GOTPCREL(%rip), %rax
+ .size _start, .-_start
diff --git a/gold/testsuite/x86_64_mov_to_lea3.s b/gold/testsuite/x86_64_mov_to_lea3.s
new file mode 100644
index 0000000..ac43b78
--- /dev/null
+++ b/gold/testsuite/x86_64_mov_to_lea3.s
@@ -0,0 +1,10 @@
+ .text
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl _start
+ .type _start, @function
+_start:
+ movq foo@GOTPCREL(%rip), %rax
+ .size _start, .-_start
diff --git a/gold/testsuite/x86_64_mov_to_lea4.s b/gold/testsuite/x86_64_mov_to_lea4.s
new file mode 100644
index 0000000..37bee32
--- /dev/null
+++ b/gold/testsuite/x86_64_mov_to_lea4.s
@@ -0,0 +1,12 @@
+ .text
+ .globl foo
+ .hidden foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl _start
+ .type _start, @function
+_start:
+ movq foo@GOTPCREL(%rip), %rax
+ .size _start, .-_start