]> gcc.gnu.org Git - gcc.git/commitdiff
[PR51447] restore the global reg var before returning from main
authorAlexandre Oliva <oliva@adacore.com>
Wed, 10 Jun 2020 20:56:36 +0000 (17:56 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 10 Jun 2020 20:56:36 +0000 (17:56 -0300)
A runtime system might legitimately hold in rbx a value expected to be
preserved across the call to main, but its use as a global register
variable stops main from preserving it.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/51447
* gcc.c-torture/execute/pr51447.c (main): Preserve call-saved
register.

gcc/testsuite/gcc.c-torture/execute/pr51447.c

index 887ddb7d06778dc85881cdf1bd3fca570b875cf3..1d00953af3aa7777f2742946bba47b5d34ee0ba1 100644 (file)
@@ -14,6 +14,9 @@ int
 main (void)
 {
   __label__ nonlocal_lab;
+#ifdef __x86_64__
+  void *save = ptr;
+#endif
   __attribute__((noinline, noclone)) void
     bar (void *func)
       {
@@ -25,5 +28,8 @@ main (void)
 nonlocal_lab:
   if (ptr != &&nonlocal_lab)
     abort ();
+#ifdef __x86_64__
+  ptr = save; /* Restore the call-saved register.  */
+#endif
   return 0;
 }
This page took 0.069797 seconds and 5 git commands to generate.