aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2020-06-10 17:56:36 -0300
committerAlexandre Oliva <oliva@gnu.org>2020-06-10 17:56:36 -0300
commit06ef9c119c56568e5f77a5189aa382cb97c95a9e (patch)
tree84ad8879bdf6ecf21a79e64f09569a2e6fc0a04f /gcc
parenta9eec9625ea7165292958be04899b057804192fb (diff)
downloadgcc-06ef9c119c56568e5f77a5189aa382cb97c95a9e.zip
gcc-06ef9c119c56568e5f77a5189aa382cb97c95a9e.tar.gz
gcc-06ef9c119c56568e5f77a5189aa382cb97c95a9e.tar.bz2
[PR51447] restore the global reg var before returning from main
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr51447.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr51447.c b/gcc/testsuite/gcc.c-torture/execute/pr51447.c
index 887ddb7..1d00953 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr51447.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr51447.c
@@ -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;
}