From: Alexandre Oliva Date: Tue, 3 Sep 2019 06:06:02 +0000 (+0000) Subject: [x86 testsuite] preserve full register across main X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4a8d4a7ec496dbd6602e373dcfcb72c25c60f86;p=gcc.git [x86 testsuite] preserve full register across main This test uses a call-saved register as a global variable. It attempts to preserve its value across main, but only the lower int part is preserved, which is not good enough for x86_64, when the runtime that calls main() happens to hold something in the chosen register that is not a zero-extension from the 32-bit value, and rightfully expects the full register to remain unchanged when main() returns. for gcc/testsuite/ChangeLog * gcc.target/i386/20020616-1.c: Preserve full register across main. From-SVN: r275329 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f93d91dcac..efb25dff085 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-03 Alexandre Oliva + + * gcc.target/i386/20020616-1.c: Preserve full register across + main. + 2019-09-02 Paul Thomas PR fortran/91589 diff --git a/gcc/testsuite/gcc.target/i386/20020616-1.c b/gcc/testsuite/gcc.target/i386/20020616-1.c index 5641826b483..48dea27956c 100644 --- a/gcc/testsuite/gcc.target/i386/20020616-1.c +++ b/gcc/testsuite/gcc.target/i386/20020616-1.c @@ -2,12 +2,16 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* We need this type to be as wide as the register chosen below, so + that, when we preserve it across main, we preserve all of it. */ +typedef int __attribute__ ((mode (__word__))) reg_type; + #if !__PIC__ -register int k asm("%ebx"); +register reg_type k asm("%ebx"); #elif __amd64 -register int k asm("%r12"); +register reg_type k asm("%r12"); #else -register int k asm("%esi"); +register reg_type k asm("%esi"); #endif void __attribute__((noinline)) @@ -18,7 +22,7 @@ foo() void test() { - int i; + reg_type i; for (i = 0; i < 10; i += k) { k = 0; @@ -28,7 +32,7 @@ void test() int main() { - int old = k; + reg_type old = k; test(); k = old; return 0;