This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[x86] Make i386.exp more PIC-friendly


Some of the i386.exp tests don't work correctly if compiled as PIC.

gcc.target/i386/20020616-1.c uses the PIC register as a global asm
register, so the patch uses an alternative call-saved register instead.
All the other tests just check a new nonpic effective-target keyword.

Tested on x86_64-linux-gnu and i586-wrs-vxworks (with PIC and
non-PIC multilibs).  OK to install?

Richard


gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_nonpic): New
	procedure.
	* gcc.target/i386/20020616-1.c: Use an alternative to %ebx
	when compiling PIC.
	* gcc.target/i386/asm-4.c: Require nonpic.
	* gcc.target/i386/cmov1.c: Likewise.
	* gcc.target/i386/mul.c: Likewise.
	* gcc.target/i386/pr21291.c: Require nonpic or ! ilp32.
	* gcc.target/i386/ssetype-1.c: Require nonpic.
	* gcc.target/i386/ssetype-3.c: Likewise.
	* gcc.target/i386/ssetype-5.c: Likewise.

Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp	(revision 123084)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -527,6 +527,16 @@ proc check_effective_target_mpaired_sing
     } "-mpaired-single"]
 }
 
+# Return 1 if the current multilib does not generate PIC by default.
+
+proc check_effective_target_nonpic { } {
+    return [check_no_compiler_messages nonpic assembly {
+	#if __PIC__
+	#error FOO
+	#endif
+    }]
+}
+
 # Return 1 if the target does not use a status wrapper.
 
 proc check_effective_target_unwrapped { } {
Index: gcc/testsuite/gcc.target/i386/20020616-1.c
===================================================================
--- gcc/testsuite/gcc.target/i386/20020616-1.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/20020616-1.c	(working copy)
@@ -2,7 +2,13 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-O2" } */
 
+#if !__PIC__
 register int k asm("%ebx");
+#elif __amd64
+register int k asm("%r12");
+#else
+register int k asm("%esi");
+#endif
 
 void __attribute__((noinline))
 foo()
Index: gcc/testsuite/gcc.target/i386/asm-4.c
===================================================================
--- gcc/testsuite/gcc.target/i386/asm-4.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/asm-4.c	(working copy)
@@ -2,6 +2,8 @@
    taken in C code, don't use alternate calling convention for local
    functions on IA-32.  */
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* The asm in this test uses an absolute address.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2" } */
 
 extern void abort (void);
Index: gcc/testsuite/gcc.target/i386/cmov1.c
===================================================================
--- gcc/testsuite/gcc.target/i386/cmov1.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/cmov1.c	(working copy)
@@ -1,4 +1,6 @@
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* This test checks for absolute memory operands.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2 -march=k8" } */
 /* { dg-final { scan-assembler "sar\[^\\n\]*magic_namea" } } */
 /* { dg-final { scan-assembler "sar\[^\\n\]*magic_nameb" } } */
Index: gcc/testsuite/gcc.target/i386/mul.c
===================================================================
--- gcc/testsuite/gcc.target/i386/mul.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/mul.c	(working copy)
@@ -1,4 +1,6 @@
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* This test checks for absolute memory operands.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2 -march=k8" } */
 /* { dg-final { scan-assembler "and\[^\\n\]*magic" } } */
 
Index: gcc/testsuite/gcc.target/i386/pr21291.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr21291.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/pr21291.c	(working copy)
@@ -1,4 +1,9 @@
-/* { dg-do compile } */
+/* The asm has 2 "r" in/out operands, 1 earlyclobber "r" output, 1 "r"
+   input and 2 fixed "r" clobbers (eax and edx), so there are a total of
+   6 registers that must not conflict.  Add to that the PIC register,
+   the frame pointer, and the stack pointer, and we've run out of
+   registers on 32-bit targets.  */
+/* { dg-do compile { target { { ! ilp32 } || nonpic } } } */
 /* { dg-options "-O" } */
 
 typedef unsigned long bngdigit;
Index: gcc/testsuite/gcc.target/i386/ssetype-1.c
===================================================================
--- gcc/testsuite/gcc.target/i386/ssetype-1.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/ssetype-1.c	(working copy)
@@ -1,4 +1,6 @@
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* This test checks for absolute memory operands.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2 -msse2 -march=k8" } */
 /* { dg-final { scan-assembler "andpd\[^\\n\]*magic" } } */
 /* { dg-final { scan-assembler "andnpd\[^\\n\]*magic" } } */
Index: gcc/testsuite/gcc.target/i386/ssetype-3.c
===================================================================
--- gcc/testsuite/gcc.target/i386/ssetype-3.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/ssetype-3.c	(working copy)
@@ -1,4 +1,6 @@
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* This test checks for absolute memory operands.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2 -msse2 -march=k8" } */
 /* { dg-final { scan-assembler "andps\[^\\n\]*magic" } } */
 /* { dg-final { scan-assembler "andnps\[^\\n\]*magic" } } */
Index: gcc/testsuite/gcc.target/i386/ssetype-5.c
===================================================================
--- gcc/testsuite/gcc.target/i386/ssetype-5.c	(revision 123084)
+++ gcc/testsuite/gcc.target/i386/ssetype-5.c	(working copy)
@@ -1,4 +1,6 @@
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* This test checks for absolute memory operands.  */
+/* { dg-require-effective-target nonpic } */
 /* { dg-options "-O2 -msse2 -march=k8" } */
 /* { dg-final { scan-assembler "pand\[^\\n\]*magic" } } */
 /* { dg-final { scan-assembler "pandn\[^\\n\]*magic" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]