This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Yet another PREFERRED_STACK_BOUNDARY fix and sanity check
- To: egcs-patches at egcs dot cygnus dot com, rth at cygnus dot com
- Subject: Yet another PREFERRED_STACK_BOUNDARY fix and sanity check
- From: Jan Hubicka <hubicka at atrey dot karlin dot mff dot cuni dot cz>
- Date: Fri, 7 Apr 2000 14:03:10 +0200
Hi
This patch adds more sanity checking to calls.c to verify that stack
pointer really is aligned before emit_call_1 is called.
This don't hold in one case - when nested call is done and pending_stack_adjust
is nonzero so no alignment instruction is necessary for the outer call.
Then NO_DEFER_POP is not called and stack gets missaligned by aligning it
for nested call.
I've fixed it by doing NO_DEFER_POP unconditionally now. Note that I am
aware, that this penalize nested calls even on non-i386 architectures,
but I have proper fix for this, that require quite grand revamps in the
calls.c that I want to delay until the code is more stable and other pending
stuff is done (such as emit_library_call_value_1 merger).
Honza
Fri Apr 7 13:57:16 MET DST 2000 Jan Hubicka <jh@suse.cz>
* calls.c (expand_call): Do NO_DEFER_POP unconditionally once
stack is propertly aligned; add sanity checking for aligned
stack pointer.
(expand_library_call_value_1): Add sanity checking for aligned
stack pointer.
Index: egcs/gcc/calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.115
diff -c -3 -p -r1.115 calls.c
*** calls.c 2000/04/05 01:52:54 1.115
--- calls.c 2000/04/07 11:56:37
*************** expand_call (exp, target, ignore)
*** 2671,2678 ****
- unadjusted_args_size));
/* Now that the stack is properly aligned, pops can't safely
be deferred during the evaluation of the arguments. */
- NO_DEFER_POP;
}
#endif
/* Don't try to defer pops if preallocating, not even from the first arg,
--- 2671,2678 ----
- unadjusted_args_size));
/* Now that the stack is properly aligned, pops can't safely
be deferred during the evaluation of the arguments. */
}
+ NO_DEFER_POP;
#endif
/* Don't try to defer pops if preallocating, not even from the first arg,
*************** expand_call (exp, target, ignore)
*** 2798,2803 ****
--- 2798,2809 ----
/* All arguments and registers used for the call must be set up by
now! */
+ /* Stack ought to be propertly aligned now. */
+ #ifdef PREFERRED_STACK_BOUNDARY
+ if (stack_pointer_delta & (preferred_stack_boundary / BITS_PER_UNIT - 1))
+ abort();
+ #endif
+
/* Generate the actual call instruction. */
emit_call_1 (funexp, fndecl, funtype, unadjusted_args_size,
args_size.constant, struct_value_size,
*************** emit_library_call_value_1 (retval, orgfu
*** 3681,3686 ****
--- 3687,3698 ----
/* Don't allow popping to be deferred, since then
cse'ing of library calls could delete a call and leave the pop. */
NO_DEFER_POP;
+
+ /* Stack ought to be propertly aligned now. */
+ #ifdef PREFERRED_STACK_BOUNDARY
+ if (stack_pointer_delta & (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT - 1))
+ abort();
+ #endif
/* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
will set inhibit_defer_pop to that value. */