This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: stack pointer alignment problem
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: stack pointer alignment problem
- From: Herman ten Brugge <Haj dot Ten dot Brugge at net dot HCC dot nl>
- Date: Sun, 30 Jul 2000 21:25:55 +0100 (WEST)
Hello,
I discovered a stack pointer alignment problem on the c4x target.
The code:
tst()
{
tst1();
}
Gets compiled as:
_tst:
addi 1,sp
call _tst1
addi -1,sp
rets
We do not need stack pointer alignment on the c4x target so we
defined STACK_BOUNDARY=32 (same as BITS_PER_UNIT=32). The call
to the function combine_pending_stack_adjustment_and_call resulted
in a stack adjustment of 1 in this case. The values stack_pointer_delta,
unadjusted_args_size and pending_stack_adjust are all 0.
This resulted in unadjusted_alignment being 0 and that results
in a stack pointer adjustment of 1.
With the patch below this is fixed. The addi 1,sp and addi -1,sp
are removed.
Herman.
2000-06-01 Herman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
* calls.c: Only use preferred_unit_stack_boundary when it is > 1.
--- calls.c.org Sun Jul 30 21:10:56 2000
+++ calls.c Sun Jul 30 21:10:58 2000
@@ -1913,10 +1913,13 @@ combine_pending_stack_adjustment_and_cal
adjustment = pending_stack_adjust;
/* Push enough additional bytes that the stack will be aligned
after the arguments are pushed. */
- if (unadjusted_alignment >= 0)
- adjustment -= preferred_unit_stack_boundary - unadjusted_alignment;
- else
- adjustment += unadjusted_alignment;
+ if (preferred_unit_stack_boundary > 1)
+ {
+ if (unadjusted_alignment >= 0)
+ adjustment -= preferred_unit_stack_boundary - unadjusted_alignment;
+ else
+ adjustment += unadjusted_alignment;
+ }
/* Now, sets ARGS_SIZE->CONSTANT so that we pop the right number of
bytes after the call. The right number is the entire