From 774e6b37bb2f0cd7fdc3a6df951b817f6d0f96dd Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 16 Mar 2000 16:02:42 +0100 Subject: [PATCH] calls.c (expand_call): Do sanity checking on arg_space_so_far. * calls.c (expand_call): Do sanity checking on arg_space_so_far. Update arg_space_so_far on stack adjustments. (emit_library_call, emit_library_call_value): Likewise; take into account arg_space_so_far and pending_stack_adjust when calculcating the boundary. From-SVN: r32586 --- gcc/ChangeLog | 8 ++++++ gcc/calls.c | 70 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index deeac92ea14..d75fa2d6ce6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +Thu Mar 16 16:01:30 MET 2000 Jan Hubicka + + * calls.c (expand_call): Do sanity checking on arg_space_so_far. + Update arg_space_so_far on stack adjustments. + (emit_library_call, emit_library_call_value): Likewise; take into + account arg_space_so_far and pending_stack_adjust when calculcating + the boundary. + Thu Mar 16 09:02:19 2000 Jason Eckhardt * flow.c: Move all basic block reordering code into its own file. diff --git a/gcc/calls.c b/gcc/calls.c index 7ae7b3d60f3..453544a808a 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1707,6 +1707,7 @@ expand_call (exp, target, ignore) rtx old_stack_level = 0; int old_pending_adj = 0; int old_inhibit_defer_pop = inhibit_defer_pop; + int old_arg_space_so_far = arg_space_so_far; rtx call_fusage = 0; register tree p; register int i; @@ -2380,7 +2381,10 @@ expand_call (exp, target, ignore) /* If we pushed args in forward order, perform stack alignment after pushing the last arg. */ if (argblock == 0) - anti_adjust_stack (GEN_INT (args_size.constant - unadjusted_args_size)); + { + anti_adjust_stack (GEN_INT (args_size.constant - unadjusted_args_size)); + arg_space_so_far += args_size.constant - unadjusted_args_size; + } #endif #endif @@ -2432,6 +2436,10 @@ expand_call (exp, target, ignore) FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1), valreg, old_inhibit_defer_pop, call_fusage, is_const, nothrow); + /* Stack pointer ought to be restored to the value before call. */ + if (old_arg_space_so_far != arg_space_so_far) + abort(); + /* If call is cse'able, make appropriate pair of reg-notes around it. Test valreg so we don't crash; may safely ignore `const' if return type is void. Disable for PARALLEL return values, because @@ -2740,6 +2748,7 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, struct args_size offset; struct args_size size; rtx save_area; }; struct arg *argvec; int old_inhibit_defer_pop = inhibit_defer_pop; + int old_arg_space_so_far = arg_space_so_far; rtx call_fusage = 0; int reg_parm_stack_space = 0; int nothrow; @@ -2883,8 +2892,14 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, original_args_size = args_size; #ifdef PREFERRED_STACK_BOUNDARY - args_size.constant = (((args_size.constant + (STACK_BYTES - 1)) - / STACK_BYTES) * STACK_BYTES); + args_size.constant = (((args_size.constant + + arg_space_so_far + + pending_stack_adjust + + STACK_BYTES - 1) + / STACK_BYTES + * STACK_BYTES) + - arg_space_so_far + - pending_stack_adjust); #endif args_size.constant = MAX (args_size.constant, @@ -2954,8 +2969,11 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, /* If we push args individually in reverse order, perform stack alignment before the first push (the last arg). */ if (argblock == 0) - anti_adjust_stack (GEN_INT (args_size.constant - - original_args_size.constant)); + { + anti_adjust_stack (GEN_INT (args_size.constant + - original_args_size.constant)); + arg_space_so_far += args_size.constant - original_args_size.constant; + } #endif #endif @@ -3086,6 +3104,7 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0, argblock, GEN_INT (argvec[argnum].offset.constant), reg_parm_stack_space, ARGS_SIZE_RTX (alignment_pad)); + arg_space_so_far += argvec[argnum].size.constant; #ifdef ACCUMULATE_OUTGOING_ARGS /* Now mark the segment we just used. */ @@ -3102,8 +3121,11 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, /* If we pushed args in forward order, perform stack alignment after pushing the last arg. */ if (argblock == 0) - anti_adjust_stack (GEN_INT (args_size.constant - - original_args_size.constant)); + { + anti_adjust_stack (GEN_INT (args_size.constant + - original_args_size.constant)); + arg_space_so_far += args_size.constant - original_args_size.constant; + } #endif #endif @@ -3174,6 +3196,10 @@ emit_library_call VPARAMS((rtx orgfun, int no_queue, enum machine_mode outmode, pop_temp_slots (); + /* Stack pointer ought to be restored to the value before call. */ + if (old_arg_space_so_far != arg_space_so_far) + abort(); + /* Now restore inhibit_defer_pop to its actual original value. */ OK_DEFER_POP; @@ -3259,6 +3285,7 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, struct args_size offset; struct args_size size; rtx save_area; }; struct arg *argvec; int old_inhibit_defer_pop = inhibit_defer_pop; + int old_arg_space_so_far = arg_space_so_far; rtx call_fusage = 0; rtx mem_value = 0; int pcc_struct_value = 0; @@ -3474,8 +3501,14 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, original_args_size = args_size; #ifdef PREFERRED_STACK_BOUNDARY - args_size.constant = (((args_size.constant + (STACK_BYTES - 1)) - / STACK_BYTES) * STACK_BYTES); + args_size.constant = (((args_size.constant + + arg_space_so_far + + pending_stack_adjust + + STACK_BYTES - 1) + / STACK_BYTES + * STACK_BYTES) + - arg_space_so_far + - pending_stack_adjust); #endif args_size.constant = MAX (args_size.constant, @@ -3545,8 +3578,11 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, /* If we push args individually in reverse order, perform stack alignment before the first push (the last arg). */ if (argblock == 0) - anti_adjust_stack (GEN_INT (args_size.constant - - original_args_size.constant)); + { + anti_adjust_stack (GEN_INT (args_size.constant + - original_args_size.constant)); + arg_space_so_far += args_size.constant - original_args_size.constant; + } #endif #endif @@ -3677,6 +3713,7 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, emit_push_insn (val, mode, NULL_TREE, NULL_RTX, 0, partial, reg, 0, argblock, GEN_INT (argvec[argnum].offset.constant), reg_parm_stack_space, ARGS_SIZE_RTX (alignment_pad)); + arg_space_so_far += argvec[argnum].size.constant; #ifdef ACCUMULATE_OUTGOING_ARGS /* Now mark the segment we just used. */ @@ -3693,8 +3730,11 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, /* If we pushed args in forward order, perform stack alignment after pushing the last arg. */ if (argblock == 0) - anti_adjust_stack (GEN_INT (args_size.constant - - original_args_size.constant)); + { + anti_adjust_stack (GEN_INT (args_size.constant + - original_args_size.constant)); + arg_space_so_far += args_size.constant - unadjusted_args_size; + } #endif #endif @@ -3778,6 +3818,10 @@ emit_library_call_value VPARAMS((rtx orgfun, rtx value, int no_queue, pop_temp_slots (); + /* Stack pointer ought to be restored to the value before call. */ + if (old_arg_space_so_far != arg_space_so_far) + abort(); + /* Copy the value to the right place. */ if (outmode != VOIDmode) { -- 2.30.2