[Patch] New -fstack-check implementation (2/n)
Eric Botcazou
ebotcazou@adacore.com
Thu Oct 29 17:18:00 GMT 2009
> OK, I've removed all the non-essential bits from the patch and left some
> broken stuff in the compiler as-is. This implements working stack checking
> for x86/x86-64, Linux and Solaris only. Full ACATS passes with
> -fstack-check as well as with -O2 -fstack-check.
Updated patch, the Ada bits have been installed independently in-between.
Re-tested on i586-suse-linux, OK for mainline?
2009-10-29 Eric Botcazou <ebotcazou@adacore.com>
PR target/10127
PR ada/20548
* expr.h (STACK_CHECK_PROBE_INTERVAL): Delete.
(STACK_CHECK_PROBE_INTERVAL_EXP): New macro.
(STACK_CHECK_MOVING_SP): Likewise.
* system.h (STACK_CHECK_PROBE_INTERVAL): Poison it.
* doc/tm.texi (Stack Checking): Delete STACK_CHECK_PROBE_INTERVAL.
Document STACK_CHECK_PROBE_INTERVAL_EXP and STACK_CHECK_MOVING_SP.
* explow.c (anti_adjust_stack_and_probe): New function.
(allocate_dynamic_stack_space): Do not directly allocate space if
STACK_CHECK_MOVING_SP, instead invoke above function.
(emit_stack_probe): Handle probe_stack insn.
(PROBE_INTERVAL): New macro.
(STACK_GROW_OPTAB): Likewise.
(STACK_HIGH, STACK_LOW): Likewise.
(probe_stack_range): Remove support code for dedicated pattern. Fix
loop condition in the small constant case. Rewrite in the general
case to be immune to wraparounds. Make sure the address of probes
is valid. Try to use [base + disp] addressing mode if possible.
* ira.c (setup_eliminable_regset): Set frame_pointer_needed if stack
checking is enabled and STACK_CHECK_MOVING_SP.
* rtlanal.c (may_trap_p_1) <MEM>: If stack checking is enabled,
return 1 for volatile references to the stack pointer.
* tree.c (build_common_builtin_nodes): Do not set ECF_NOTHROW on
__builtin_alloca if stack checking is enabled.
* unwind-dw2.c (uw_identify_context): Take into account whether the
context is that of a signal frame or not.
* config/i386/linux-unwind.h (x86_frob_update_context): New function.
(MD_FROB_UPDATE_CONTEXT): Define.
* config/i386/linux.h (STACK_CHECK_STATIC_BUILTIN): Likewise.
(STACK_CHECK_MOVING_SP): Likewise.
* config/i386/linux64.h (STACK_CHECK_STATIC_BUILTIN): Likewise.
(STACK_CHECK_MOVING_SP): Likewise.
* config/i386/sol2.h (STACK_CHECK_STATIC_BUILTIN): Likewise.
* config/i386/i386.c (ix86_compute_frame_layout): Force use of push
instructions to save registers if stack checking with probes is on.
(get_scratch_register_on_entry): New function.
(release_scratch_register_on_entry): Likewise.
(output_probe_op): Likewise.
(output_adjust_stack_and_probe_op): Likewise.
(output_adjust_stack_and_probe): Likewise.
(ix86_gen_adjust_stack_and_probe): Likewise.
(ix86_adjust_stack_and_probe): Likewise.
(output_probe_stack_range_op): Likewise.
(ix86_gen_probe_stack_range): Likewise
(ix86_emit_probe_stack_range): Likewise.
(ix86_expand_prologue): Emit stack checking code if static builtin
stack checking is enabled.
* config/i386/i386-protos.h (output_adjust_stack_and_probe): Declare.
(output_probe_stack_range): Likewise.
* config/i386/i386.md (UNSPECV_STACK_PROBE_INLINE): New constant.
(probe_stack): New expander.
(adjust_stack_and_probe): New insn.
(probe_stack_range): Likewise.
(logical operation peepholes): Do not split stack checking probes.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-45_stack-check-2c.diff
Type: text/x-diff
Size: 40704 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091029/5e0ecb33/attachment.bin>
More information about the Gcc-patches
mailing list