This test was failing because it was checking that eax was being cleared. For
sysv abi, eax contains the number of XMM registers used in the call, but msabi
just passes the float arguments twice, both in xmm and general purpose 
registers.

This patch adds tests for both sysv and msabi functions being called, and adds
some more tests that check for for argument being placed in the correct
register.

Tested on x86_64-linux-gnu and x86_64-w64-mingw32

gcc/testsuite:
        PR testsuite/119765
        * gcc.target/i386/amd64-abi-9.c: Add sysv attribute to called function
        Add msabi attribute function
        Add test checking parameter is placed in correct register

Co-Authored-By: NightStrike <nightstr...@gmail.com>
Signed-off-by: Peter Damianov <peter0...@disroot.org>
---
v2: Remove superflous \[ in regex

 gcc/testsuite/gcc.target/i386/amd64-abi-9.c | 38 ++++++++++++++++++---
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/amd64-abi-9.c 
b/gcc/testsuite/gcc.target/i386/amd64-abi-9.c
index 9b2cd7e7b49..1a23f6d8a73 100644
--- a/gcc/testsuite/gcc.target/i386/amd64-abi-9.c
+++ b/gcc/testsuite/gcc.target/i386/amd64-abi-9.c
@@ -1,18 +1,46 @@
 /* { dg-do compile { target { ! ia32 } } } */
 /* { dg-options "-O2 -mno-sse -mno-skip-rax-setup" } */
+
+// For sysv abi, eax holds the number of XMM registers used in the call.
+// Since sse is disabled, check that it is zeroed
 /* { dg-final { scan-assembler-times "xorl\[\\t \]*\\\%eax,\[\\t \]*%eax" 2 } 
} */
 
-void foo (const char *, ...);
+// For ms abi, the argument should go in edx
+/* { dg-final { scan-assembler-times "movl\[\\t \]*\\\$20,\[\\t \]*%edx" 2 } } 
*/
+
+// For sysv abi, the argument should go in esi
+/* { dg-final { scan-assembler-times "movl\[\\t \]*\\\$20,\[\\t \]*%esi" 2 } } 
*/
+
+void
+__attribute__((__sysv_abi__))
+fooSys (const char *, ...);
+
+void
+test_sys1 (void)
+{
+  fooSys ("%d", 20);
+}
+
+int
+test_sys2 (void)
+{
+  fooSys ("%d", 20);
+  return 3;
+}
+
+void
+__attribute__((__ms_abi__))
+fooMs (const char *, ...);
 
 void
-test1 (void)
+test_ms1 (void)
 {
-  foo ("%d", 20);
+  fooMs ("%d", 20);
 }
 
 int
-test2 (void)
+test_ms2 (void)
 {
-  foo ("%d", 20);
+  fooMs ("%d", 20);
   return 3;
 }
-- 
2.39.5

Reply via email to