re PR target/85511 ([X86] Using __builtin_ia32_writeeflags_u32 in 64-bit mode causes...
authorJakub Jelinek <jakub@redhat.com>
Tue, 24 Apr 2018 16:42:59 +0000 (18:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 24 Apr 2018 16:42:59 +0000 (18:42 +0200)
PR target/85511
* config/i386/i386.c (ix86_init_mmx_sse_builtins): Don't define
__builtin_ia32_readeflags_u32 and __builtin_ia32_writeeflags_u32
if TARGET_64BIT.

* gcc.target/i386/pr85511.c: New test.

From-SVN: r259609

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr85511.c [new file with mode: 0644]

index e43a931c1922132340faea26c2cc5a66fbc77a50..299206492a7d93aed58621e04df818efe8fe271e 100644 (file)
@@ -1,5 +1,10 @@
 2018-04-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/85511
+       * config/i386/i386.c (ix86_init_mmx_sse_builtins): Don't define
+       __builtin_ia32_readeflags_u32 and __builtin_ia32_writeeflags_u32
+       if TARGET_64BIT.
+
        PR target/85503
        * config/rs6000/rs6000-p8swap.c (const_load_sequence_p): Punt if
        const_vector is not CONST_VECTOR or SYMBOL_REF for a constant pool
index fada22bba7021a97725c766092385c89bac55861..a3c3870d4f4df4c2c2b5dff1954e69de474dfae1 100644 (file)
@@ -31934,14 +31934,20 @@ ix86_init_mmx_sse_builtins (void)
               IX86_BUILTIN_SBB64);
 
   /* Read/write FLAGS.  */
-  def_builtin (0, "__builtin_ia32_readeflags_u32",
-               UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
-  def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_readeflags_u64",
-               UINT64_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
-  def_builtin (0, "__builtin_ia32_writeeflags_u32",
-               VOID_FTYPE_UNSIGNED, IX86_BUILTIN_WRITE_FLAGS);
-  def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_writeeflags_u64",
-               VOID_FTYPE_UINT64, IX86_BUILTIN_WRITE_FLAGS);
+  if (TARGET_64BIT)
+    {
+      def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_readeflags_u64",
+                  UINT64_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
+      def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_writeeflags_u64",
+                  VOID_FTYPE_UINT64, IX86_BUILTIN_WRITE_FLAGS);
+    }
+  else
+    {
+      def_builtin (0, "__builtin_ia32_readeflags_u32",
+                  UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
+      def_builtin (0, "__builtin_ia32_writeeflags_u32",
+                  VOID_FTYPE_UNSIGNED, IX86_BUILTIN_WRITE_FLAGS);
+    }
 
   /* CLFLUSHOPT.  */
   def_builtin (OPTION_MASK_ISA_CLFLUSHOPT, "__builtin_ia32_clflushopt",
index 0c1c0be9e91175e051ddb3bd2b48225fa5e37f74..12fd465de84719fc467e32783d06d71f300be9a1 100644 (file)
@@ -1,5 +1,8 @@
 2018-04-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/85511
+       * gcc.target/i386/pr85511.c: New test.
+
        PR target/85503
        * g++.dg/ext/pr85503.C: New test.
 
diff --git a/gcc/testsuite/gcc.target/i386/pr85511.c b/gcc/testsuite/gcc.target/i386/pr85511.c
new file mode 100644 (file)
index 0000000..a082a5e
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR target/85511 */
+/* { dg-do compile } */
+/* { dg-options "-Wimplicit-function-declaration" } */
+
+unsigned int
+foo (void)
+{
+  return __builtin_ia32_readeflags_u32 ();     /* { dg-warning "implicit declaration of function" "" { target { ! ia32 } } } */
+}
+
+void
+bar (unsigned int x)
+{
+  __builtin_ia32_writeeflags_u32 (x);          /* { dg-warning "implicit declaration of function" "" { target { ! ia32 } } } */
+}