This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trans-mem] add REGPARM calling sequence to GTM_longjmp


On ia-32, GTM_longjmp() is used as if we had the regparm calling
sequence, but the function's prototype uses the normal stack calling
sequence.

When we use GTM_longjmp in beginend.cc, we use the standard ia32 calling
sequence:

        movl    %edx, 8(%esp)
        movl    %eax, 4(%esp)
        movl    %ebx, (%esp)
        call    GTM_longjmp

But the library implementation config/x86/sjlj.S expects the first two
arguments in AX and DX as per REGPARM:

GTM_longjmp:
	.cfi_startproc
...
...
;; ia32 implementation
	xchgl	%eax, %edx		<--	First two args in ax/dx
	movl	(%edx), %ecx
	movl	4(%edx), %ebx
	movl	8(%edx), %esi
	movl	12(%edx), %edi
	movl	16(%edx), %ebp
	movl	20(%edx), %edx
	.cfi_def_cfa %ecx, 0
	.cfi_register %eip, %edx
	movl	%ecx, %esp
	jmp	*%edx

The following patch fixes the calling sequence on the prototype for
GTM_longjmp, as well as adding some comments throughout.

Tested by manual inspection of the assembly, since ia32 tests fail
with a link error I'm investigating (prior to my patch).

OK for branch?

	* libitm_i.h (GTM_longjmp): Add ITM_REGPARM.

Index: config/linux/rwlock.h
===================================================================
--- config/linux/rwlock.h	(revision 156783)
+++ config/linux/rwlock.h	(working copy)
@@ -48,9 +48,9 @@ class gtm_rwlock
 
   // All fields must be "int", since they're all given to the futex syscall.
   int summary;
-  int a_readers;
-  int w_readers;
-  int w_writers;
+  int a_readers;		// Number of active readers.
+  int w_readers;		// Number of waiting readers.
+  int w_writers;       		// Number of waiting writers.
 
   int lock_summary ();
 
Index: libitm_i.h
===================================================================
--- libitm_i.h	(revision 156783)
+++ libitm_i.h	(working copy)
@@ -265,7 +265,7 @@ namespace GTM HIDDEN {
 extern uint64_t gtm_spin_count_var;
 
 extern "C" uint32_t GTM_longjmp (const gtm_jmpbuf *, uint32_t, uint32_t)
-	ITM_NORETURN;
+	ITM_NORETURN ITM_REGPARM;
 
 extern "C" void GTM_LB (const void *, size_t) ITM_REGPARM;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]