From 1df875cc44d66ca84b5dfff7fbd60ca715ca61ae Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 2 Feb 2007 12:28:27 +0000
Subject: [PATCH] 	* src/powerpc/linux64.S (ffi_call_LINUX64): Move
 restore of r2 	immediately after bctrl instruction.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121498 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libffi/ChangeLog             | 5 +++++
 libffi/src/powerpc/linux64.S | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libffi/ChangeLog b/libffi/ChangeLog
index 879df4950f4a..4b3c509f6645 100644
--- a/libffi/ChangeLog
+++ b/libffi/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+	* src/powerpc/linux64.S (ffi_call_LINUX64): Move restore of r2
+	immediately after bctrl instruction.
+
 2007-01-18  Alexandre Oliva  <aoliva@redhat.com>
 
 	* Makefile.am (all-recursive, install-recursive,
diff --git a/libffi/src/powerpc/linux64.S b/libffi/src/powerpc/linux64.S
index d72912da1edf..dbfcc7b8f3d1 100644
--- a/libffi/src/powerpc/linux64.S
+++ b/libffi/src/powerpc/linux64.S
@@ -47,8 +47,8 @@ ffi_call_LINUX64:
 	std	%r0, 16(%r1)
 
 	mr	%r28, %r1	/* our AP.  */
-	stdux	%r1, %r1, %r4
 .LCFI0:
+	stdux	%r1, %r1, %r4
 	mr	%r31, %r5	/* flags, */
 	mr	%r30, %r6	/* rvalue, */
 	mr	%r29, %r7	/* function address.  */
@@ -100,6 +100,10 @@ ffi_call_LINUX64:
 	/* Make the call.  */
 	bctrl
 
+	/* This must follow the call immediately, the unwinder
+	   uses this to find out if r2 has been saved or not.  */
+	ld	%r2, 40(%r1)
+
 	/* Now, deal with the return value.  */
 	mtcrf	0x01, %r31
 	bt-	30, .Ldone_return_value
@@ -109,7 +113,6 @@ ffi_call_LINUX64:
 
 .Ldone_return_value:
 	/* Restore the registers we used and return.  */
-	ld	%r2, 40(%r1)
 	mr	%r1, %r28
 	ld	%r0, 16(%r28)
 	ld	%r28, -32(%r1)
-- 
GitLab