https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78444

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #5)
> (In reply to Uroš Bizjak from comment #4)
> > So, what we want to achieve here?
> AFAICS, the compiler figures out that the called function requires only
> 64bit alignment and lowers the alignment requirements at the call site. So,
> although the callee is not leaf, it gets "misaligned" to 64 bit.
> 
> If there are additional requirements for the alignment at call site (c.f.
> Description), then the patch in Comment #2 is correct.

For both m32 and m64 Darwin requires 128b alignment at cll sites (256 if AVX is
used).

for sysV5 psABI targets, the call site requirement is 64 for m32 and 126/256
for m64.

As er your suggestion, I am bootstrapping/testing:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 711bec0..458430a 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -11149,8 +11149,13 @@ ix86_compute_frame_layout (void)
   /* 64-bit MS ABI seem to require stack alignment to be always 16,
      except for function prologues, leaf functions and when the defult
      incoming stack boundary is overriden at command line or via
-     force_align_arg_pointer attribute.  */
-  if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128)
+     force_align_arg_pointer attribute.
+
+     Darwin's ABI specifies 128b alignment for both 32 and  64 bit variants
+     at call sites.
+ */
+  if (((TARGET_64BIT_MS_ABI || TARGET_MACHO) 
+        && crtl->preferred_stack_boundary < 128)
       && (!crtl->is_leaf || cfun->calls_alloca != 0
          || ix86_current_function_calls_tls_descriptor
          || ix86_incoming_stack_boundary < 128))

Reply via email to