Hi, the problem is that darwin output profiler after prologue. With ACCUMULATE_OUTGOING_ARGS we leave stack pointer aligned to boundary - 4 (for return pointer) without we leave it aligned. I guess it is possible to compensate this in FUNCTION_PROFILER, but I am not convinced this will work reliably. Probably disabling combine-stack-adjustments would be needed, too. (I do not think it is reliable with ACCUMULATE_OUTGOING_ARGS either)
Honza Index: config/i386/darwin.h =================================================================== --- config/i386/darwin.h (revision 221034) +++ config/i386/darwin.h (working copy) @@ -210,6 +210,8 @@ extern int darwin_emit_branch_islands; #undef FUNCTION_PROFILER #define FUNCTION_PROFILER(FILE, LABELNO) \ do { \ + if (!ACCUMULATE_OUTGOING_ARGS) \ + fprintf (FILE, "\tpushl %%ebx\n"); /* Align stack */ \ if (TARGET_MACHO_BRANCH_ISLANDS \ && MACHOPIC_INDIRECT && !TARGET_64BIT) \ { \ @@ -218,6 +220,8 @@ extern int darwin_emit_branch_islands; machopic_validate_stub_or_non_lazy_ptr (name); \ } \ else fprintf (FILE, "\tcall mcount\n"); \ + if (!ACCUMULATE_OUTGOING_ARGS) \ + fprintf (FILE, "\tpopl %%ebx\n"); /* Align stack */ \ } while (0) #define C_COMMON_OVERRIDE_OPTIONS \ Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 221034) +++ config/i386/i386.c (working copy) @@ -10061,6 +10061,13 @@ ix86_compute_frame_layout (struct ix86_f if (crtl->stack_alignment_needed < PREFERRED_STACK_BOUNDARY) crtl->stack_alignment_needed = PREFERRED_STACK_BOUNDARY; } + /* Be sure we get stack aligned for mcount call. */ + else if (crtl->profile && flag_fentry) + { + crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY; + if (crtl->stack_alignment_needed < PREFERRED_STACK_BOUNDARY) + crtl->stack_alignment_needed = PREFERRED_STACK_BOUNDARY; + } stack_alignment_needed = crtl->stack_alignment_needed / BITS_PER_UNIT; preferred_alignment = crtl->preferred_stack_boundary / BITS_PER_UNIT;