diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-03-11 06:48:24 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-03-17 07:06:10 -0700 |
commit | adf14bdbc10d4114865a08cf20020a2616039057 (patch) | |
tree | 6d0ba9dcaffd6600c4e1068ebd04eca5562d4015 /gcc/testsuite | |
parent | 39916ceab4940315e84bcd966da2c1d4a8e1734b (diff) | |
download | gcc-adf14bdbc10d4114865a08cf20020a2616039057.zip gcc-adf14bdbc10d4114865a08cf20020a2616039057.tar.gz gcc-adf14bdbc10d4114865a08cf20020a2616039057.tar.bz2 |
x86: Update 'P' operand modifier for -fno-plt
Update 'P' operand modifier for -fno-plt to support inline assembly
statements. In 64-bit, we can always load function address with
@GOTPCREL. In 32-bit, we load function address with @GOT only for
non-PIC since PIC register may not be available at call site.
gcc/
PR target/99504
* config/i386/i386.c (ix86_force_load_from_GOT_p): Support
inline assembly statements.
(ix86_print_operand): Update 'P' handling for -fno-plt.
gcc/testsuite/
PR target/99504
* gcc.target/i386/pr99530-1.c: New test.
* gcc.target/i386/pr99530-2.c: Likewise.
* gcc.target/i386/pr99530-3.c: Likewise.
* gcc.target/i386/pr99530-4.c: Likewise.
* gcc.target/i386/pr99530-5.c: Likewise.
* gcc.target/i386/pr99530-6.c: Likewise.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-1.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-2.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-3.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-4.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-5.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr99530-6.c | 11 |
6 files changed, 66 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/pr99530-1.c b/gcc/testsuite/gcc.target/i386/pr99530-1.c new file mode 100644 index 0000000..080d7cc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fpic -mcmodel=large -fno-plt" } */ +/* { dg-final { scan-assembler-not "foo@GOTPCREL" } } */ + +extern void foo (void); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99530-2.c b/gcc/testsuite/gcc.target/i386/pr99530-2.c new file mode 100644 index 0000000..9808957 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fno-pic -mcmodel=large -fno-plt" } */ +/* { dg-final { scan-assembler-not "foo@GOTPCREL" } } */ + +extern void foo (void); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99530-3.c b/gcc/testsuite/gcc.target/i386/pr99530-3.c new file mode 100644 index 0000000..22fe81b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-options "-O2 -fno-pic -fno-plt" } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOTPCREL" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOT" { target { ia32 && got32x_reloc } } } } */ + +extern void foo (void); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99530-4.c b/gcc/testsuite/gcc.target/i386/pr99530-4.c new file mode 100644 index 0000000..aba0b5d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-options "-O2 -fpic -fno-plt" } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOTPCREL" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-not "foo@GOT" { target { ia32 } } } } */ + +extern void foo (void); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99530-5.c b/gcc/testsuite/gcc.target/i386/pr99530-5.c new file mode 100644 index 0000000..02c5799 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-5.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-options "-O2 -fno-pic" } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOTPCREL" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOT" { target { ia32 && got32x_reloc } } } } */ + +extern void foo (void) __attribute__ ((noplt)); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} diff --git a/gcc/testsuite/gcc.target/i386/pr99530-6.c b/gcc/testsuite/gcc.target/i386/pr99530-6.c new file mode 100644 index 0000000..0dfdd37 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99530-6.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-final { scan-assembler "call\[ \t\]+\[*\]foo@GOTPCREL" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-not "foo@GOT" { target { ia32 } } } } */ + +extern void foo (void) __attribute__ ((noplt)); +void +bar (void) +{ + asm ("call %P0" : : "X" (foo)); +} |