]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Disallow MMX and 80387 in no_caller_saved_registers function
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 13 Aug 2025 21:18:26 +0000 (14:18 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 14 Aug 2025 02:31:45 +0000 (19:31 -0700)
commit 9804b23198b39f85a7258be556c5e8aed44b9efc
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Apr 13 11:38:24 2025 -0700

    x86: Add preserve_none and update no_caller_saved_registers attributes

allowed MMX/80387 instructions in functions with no_caller_saved_registers
attribute by accident.  Update ix86_set_current_function to properly
check if MMX and 80387 are enabled.

gcc/

PR target/121540
* config/i386/i386-options.cc (ix86_set_current_function):
Properly check if MMX and 80387 are enabled.

gcc/testsuite/

PR target/121540
* gcc.target/i386/no-callee-saved-19a.c (dg-options): Add
"-mno-avx -mno-mmx -mno-80387"
* gcc.target/i386/no-callee-saved-19b.c: Likewise.
* gcc.target/i386/no-callee-saved-19c.c: Likewise.
* gcc.target/i386/no-callee-saved-19d.c: Likewise.
* gcc.target/i386/no-callee-saved-19e.c: Likewise.
* gcc.target/i386/pr121208-1a.c: Likewise.
* gcc.target/i386/pr121208-1b.c: Likewise.
* gcc.target/i386/pr121540-1.c: New test.
* gcc.target/i386/pr121540-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
gcc/config/i386/i386-options.cc
gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
gcc/testsuite/gcc.target/i386/no-callee-saved-19b.c
gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
gcc/testsuite/gcc.target/i386/no-callee-saved-19e.c
gcc/testsuite/gcc.target/i386/pr121208-1a.c
gcc/testsuite/gcc.target/i386/pr121208-1b.c
gcc/testsuite/gcc.target/i386/pr121540-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr121540-2.c [new file with mode: 0644]

index 09a35ef629802174c87fe6460b61aa3a914ce6b2..136c0f2e9663ddfe612f472f1393b3ffcc456846 100644 (file)
@@ -3556,6 +3556,10 @@ ix86_set_current_function (tree fndecl)
            isa = "AVX";
          else if (cfun->machine->func_type != TYPE_NORMAL)
            isa = "SSE";
+         else if (TARGET_MMX)
+           isa = "MMX/3Dnow";
+         else if (TARGET_80387)
+           isa = "80387";
          else
            isa = NULL;
        }
index 12f35cfa8bba9247324042701feff703de1ad0ce..3ba578df8c297f121480b08d379e95220325c09c 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { *-*-linux* && lp64 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  } } */
 
index c9343a65470276288d688e4277d54ea2f421b2e8..dc38936a61a9497f2d108b8f1a8e30b16d523376 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { *-*-linux* && maybe_x32 } } } */
-/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mno-apxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  } } */
 
index 05aca9f4b119d917ab166684bf32c0f2a964f30d..e7f247b723cb68527b9a9173ed042166be48247d 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { *-*-linux* && ia32 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  } } */
 
index b3caa3d81b2dbcbb81ea2aa81b99eac34bff31f4..4657e170350b2ff5cec400f46db3317bd0b738fa 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { *-*-linux* && lp64 } } } */
-/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  } } */
 
index 3fcb41ff196975a142b3fb20d4499ca96db22189..8e0bbe82eae0f00e1cad4090948ec06afc2ace5d 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { *-*-linux* && maybe_x32 } } } */
-/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* { dg-options "-O2 -mx32 -fno-pic -mtune=generic -msse2 -mno-avx -mno-mmx -mno-80387 -mapxf -mtune-ctrl=prologue_using_move,epilogue_using_move" } */
 /* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
 /* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  } } */
 
index cb8bd0bc8d280b6214caceed6cc6e984e5a2b5e4..f799bc81d4d85c01f47782d2da2d76aad7e5e80e 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target *-*-linux* } } */
-/* { dg-options "-O2 -fPIC -mno-80387 -mtls-dialect=gnu" } */
+/* { dg-options "-O2 -fPIC -mno-avx -mno-mmx -mno-80387 -mtls-dialect=gnu" } */
 
 extern __thread int bar;
 extern void func (void);
index 037e9a0899c1c33ff105bbaba2713d9f38121e2a..ba37abccfc00adc1f3fc86cd302c50dea773d4f1 100644 (file)
@@ -1,4 +1,4 @@
 /* { dg-do compile { target *-*-linux* } } */
-/* { dg-options "-O2 -fPIC -mno-80387 -mtls-dialect=gnu2" } */
+/* { dg-options "-O2 -fPIC -mno-avx -mno-mmx -mno-80387 -mtls-dialect=gnu2" } */
 
 #include "pr121208-1a.c"
diff --git a/gcc/testsuite/gcc.target/i386/pr121540-1.c b/gcc/testsuite/gcc.target/i386/pr121540-1.c
new file mode 100644 (file)
index 0000000..dee9c27
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64" } */
+
+void
+ __attribute__ ((no_caller_saved_registers))
+fn (void)
+{ /* { dg-message "sorry, unimplemented: MMX/3Dnow instructions aren't allowed" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr121540-2.c b/gcc/testsuite/gcc.target/i386/pr121540-2.c
new file mode 100644 (file)
index 0000000..15a3f40
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64 -mno-mmx" } */
+
+void
+ __attribute__ ((no_caller_saved_registers))
+fn (void)
+{ /* { dg-message "sorry, unimplemented: 80387 instructions aren't allowed" } */
+}