Commit e4a8d4a7 by Alexandre Oliva Committed by Alexandre Oliva

[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
parent 97d6a7c8
2019-09-03 Alexandre Oliva <oliva@adacore.com>
* gcc.target/i386/20020616-1.c: Preserve full register across
main.
2019-09-02 Paul Thomas <pault@gcc.gnu.org> 2019-09-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/91589 PR fortran/91589
......
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
/* { dg-do run } */ /* { dg-do run } */
/* { dg-options "-O2" } */ /* { 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__ #if !__PIC__
register int k asm("%ebx"); register reg_type k asm("%ebx");
#elif __amd64 #elif __amd64
register int k asm("%r12"); register reg_type k asm("%r12");
#else #else
register int k asm("%esi"); register reg_type k asm("%esi");
#endif #endif
void __attribute__((noinline)) void __attribute__((noinline))
...@@ -18,7 +22,7 @@ foo() ...@@ -18,7 +22,7 @@ foo()
void test() void test()
{ {
int i; reg_type i;
for (i = 0; i < 10; i += k) for (i = 0; i < 10; i += k)
{ {
k = 0; k = 0;
...@@ -28,7 +32,7 @@ void test() ...@@ -28,7 +32,7 @@ void test()
int main() int main()
{ {
int old = k; reg_type old = k;
test(); test();
k = old; k = old;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment