From: H.J. Lu Date: Sun, 9 Mar 2025 14:00:23 +0000 (-0700) Subject: i386: Verify that argument registers are spilled properly X-Git-Tag: basepoints/gcc-16~1596 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06440e726acfa9c9695a07dc524a832a53057ad6;p=thirdparty%2Fgcc.git i386: Verify that argument registers are spilled properly While working on a local x86 patch, which passed the GCC testsuite, I got a compiler error: In function ‘paravirt_read_msr’, inlined from ‘perf_ibs_handle_irq’ at arch/x86/events/amd/ibs.c:1055:2: ./arch/x86/include/asm/paravirt_types.h:397:17: error: ‘asm’ operand has impossible constraints or there are not enough registers 397 | asm volatile(ALTERNATIVE(PARAVIRT_CALL, ALT_CALL_INSTR, \ | ^~~ when building x86-64 Linux kernel. RDI, RSI, RDX and RCX registers are used to pass arguments in 64-bit mode. EAX, EDX and ECX registers are used to pass arguments in 32-bit mode. But there is no coverage in the GCC testsuite. Add tests to verify that argument registers are spilled properly. PR target/119171 * gcc.target/i386/pr119171-1.c: New test. * gcc.target/i386/pr119171-2.c: Likewise. Signed-off-by: H.J. Lu --- diff --git a/gcc/testsuite/gcc.target/i386/pr119171-1.c b/gcc/testsuite/gcc.target/i386/pr119171-1.c new file mode 100644 index 00000000000..a017e6e215f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr119171-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +extern long a1, a2, a3, a4; +extern void foo (void *, void *, void *, void *); +void +bar (void *rdi, void *rsi, void *rdx, void *rcx) +{ + asm ("" : "=D"(a1) : "D"(0)); + asm ("" : "=S"(a2) : "S"(0)); + asm ("" : "=d"(a3) : "d"(0)); + asm ("" : "=c"(a4) : "c"(0)); + foo (rdi, rsi, rdx, rcx); +} diff --git a/gcc/testsuite/gcc.target/i386/pr119171-2.c b/gcc/testsuite/gcc.target/i386/pr119171-2.c new file mode 100644 index 00000000000..5c209f9aed0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr119171-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -mregparm=3" } */ + +extern long a1, a2, a3; +extern void foo (void *, void *, void *); +void +bar (void *eax, void *edx, void *ecx) +{ + asm ("" : "=a"(a1) : "a"(0)); + asm ("" : "=d"(a2) : "d"(0)); + asm ("" : "=c"(a3) : "c"(0)); + foo (eax, edx, ecx); +}