diff mbox

RFA: Fix calculation of size of builtin setjmp buffer

Message ID 5375CC7B.7070202@redhat.com
State New
Headers show

Commit Message

Nick Clifton May 16, 2014, 8:29 a.m. UTC
Hi Eric,

   OK - here is your version of the patch, extended with a comment which 
I think is helpful for other people reading the code, and with the 
changes to builtins.c and md.texi removed, since the size of the buffer 
is not changing.

   Is this version OK to apply ?

Cheers
   Nick

gcc/ChangeLog
2014-05-16  Nick Clifton  <nickc@redhat.com>

	* except.c (init_eh): Correct computation of the size of a builtin
	setjmp buffer for when pointers are bigger than words.

Comments

Eric Botcazou May 16, 2014, 4:56 p.m. UTC | #1
>    OK - here is your version of the patch, extended with a comment which
> I think is helpful for other people reading the code, and with the
> changes to builtins.c and md.texi removed, since the size of the buffer
> is not changing.
> 
>    Is this version OK to apply ?

Yes, IMO that's fine, thanks.
diff mbox

Patch

Index: gcc/except.c
===================================================================
--- gcc/except.c	(revision 210490)
+++ gcc/except.c	(working copy)
@@ -286,9 +286,22 @@ 
        tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1);
  #endif
  #else
-      /* builtin_setjmp takes a pointer to 5 words.  */
-      tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
+      /* Compute a minimally sized jump buffer.  We need room to store at
+	 least 3 pointers - stack pointer, frame pointer and return address.
+	 Plus for some targets we need room for an extra pointer - in the
+	 case of MIPS this is the global pointer.  This makes a total of four
+	 pointers, but to be safe we actually allocate room for 5.
+
+	 If pointers are smaller than words then we allocate enough room for
+	 5 words, just in case the backend needs this much room.  For more
+	 discussion on this issue see:
+	 http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00313.html.  */
+      if (POINTER_SIZE > BITS_PER_WORD)
+	tmp = size_int (5 - 1);
+      else
+	tmp = size_int ((5 * BITS_PER_WORD / POINTER_SIZE) - 1);
  #endif
        tmp = build_index_type (tmp);
        tmp = build_array_type (ptr_type_node, tmp);