remaining new darwin regressions

Mike Stump mrs@apple.com
Wed Jan 21 18:44:00 GMT 2009


On Jan 20, 2009, at 11:22 PM, Jack Howarth wrote:
>   Are there any observations that you could make concerning
> the thread...
>
> http://gcc.gnu.org/ml/gcc/2009-01/msg00297.html

Sure, in i386/darwin.h we have:

/* Since we'll never want a stack boundary less aligned than 128 bits
    we need the extra work here otherwise bits of gcc get very grumpy
    when we ask for lower alignment.  We could just reject values less
    than 128 bits for Darwin, but it's easier to up the alignment if
    it's below the minimum.  */
#undef PREFERRED_STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY                        \
   MAX (STACK_BOUNDARY, ix86_preferred_stack_boundary)

This selects the maximal alignment to be 128 (16-bytes), the testcase  
works for all alignments of 16-bytes or less.  For more aligning, I  
think that MAX, should be just a MIN:

/* Since we'll never want a stack boundary less aligned than 128 bits
    we need the extra work here otherwise bits of gcc get very grumpy
    when we ask for lower alignment.  We could just reject values less
    than 128 bits for Darwin, but it's easier to up the alignment if
    it's below the minimum.  */
#undef PREFERRED_STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY                        \
   MIN (STACK_BOUNDARY, ix86_preferred_stack_boundary)

this way, the code actually matches the comment as well.  Plus, this  
then more closely matches non-darwin x86 machines:

/* Boundary (in *bits*) on which the stack pointer prefers to be
    aligned; the compiler cannot rely on having this alignment.  */
#define PREFERRED_STACK_BOUNDARY ix86_preferred_stack_boundary

GIve that a try and let me know if it works.  Seems to have been  
caused by -r132332:

r125695 | echristo | 2007-06-13 18:53:17 -0700 (Wed, 13 Jun 2007) | 5  
lines

2007-06-13  Eric Christopher  <echristo@apple.com>

             * config/i386/darwin.h (PREFERRED_STACK_BOUNDARY): Don't  
let
             the user set a value below STACK_BOUNDARY.

No testcase, bad, plus, the code:

Index: darwin.h
===================================================================
--- darwin.h	(revision 125694)
+++ darwin.h	(revision 125695)
@@ -75,6 +75,16 @@
  #undef STACK_BOUNDARY
  #define STACK_BOUNDARY 128

+/* Since we'll never want a stack boundary less aligned than 128 bits
+   we need the extra work here otherwise bits of gcc get very grumpy
+   when we ask for lower alignment.  We could just reject values less
+   than 128 bits for Darwin, but it's easier to up the alignment if
+   it's below the minimum.  */
+#undef PREFERRED_STACK_BOUNDARY
+#define PREFERRED_STACK_BOUNDARY (ix86_preferred_stack_boundary > 128	\
+				  ? ix86_preferred_stack_boundary	\
+				  : 128)
+
  /* We want -fPIC by default, unless we're using -static to compile for
     the kernel or some such.  */


doesn't seem to match the comment, bad.  When researching, we find:

http://gcc.gnu.org/ml/gcc-bugs/2008-02/msg01394.html

IMO, there is no need for extra paranoia in darwin.h and following  
defines
should be removed:

/* On Darwin, the stack is 128-bit aligned at the point of every call.
    Failure to ensure this will lead to a crash in the system libraries
    or dynamic loader.  */
#undef STACK_BOUNDARY
#define STACK_BOUNDARY 128

/* Since we'll never want a stack boundary less aligned than 128 bits
    we need the extra work here otherwise bits of gcc get very grumpy
    when we ask for lower alignment.  We could just reject values less
    than 128 bits for Darwin, but it's easier to up the alignment if
    it's below the minimum.  */
#undef PREFERRED_STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY (ix86_preferred_stack_boundary >  
128   \
                                   ?  
ix86_preferred_stack_boundary       \
                                   : 128)

(Could someone with darwin bootstraps and regtest removal of these  
defines? Do
we even have an example of a failure for latest 4.3 if these are not  
defined?)


 From the original email to patches:

So, with the change to specify STACK_BOUNDARY to 128, bits of gcc get  
grumpy if we set the preferred stack boundary to less than that. Since  
a value less than 128 doesn't really make sense and erroring out (or  
warning) is less than friendly for no reason here I'm just making it a  
minimum. It also fixes a few testcases.

Committed to mainline after testing on x86-darwin.

-eric

2007-06-13  Eric Christopher  <echristo@apple.com>

	* config/i386/darwin.h (PREFERRED_STACK_BOUNDARY): Don't let
	the user set a value below STACK_BOUNDARY.



More information about the Gcc mailing list