aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/alpha
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2010-08-30 20:04:49 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-08-30 20:04:49 +0000
commitd3c12306971946ab9a9d644ddf7b26e9383d2391 (patch)
treeca99479811fedf830873973cdd6050ed0d345e29 /gcc/config/alpha
parent1987baa3aba544cf7dd4d6273e26b54003b96cf7 (diff)
downloadgcc-d3c12306971946ab9a9d644ddf7b26e9383d2391.zip
gcc-d3c12306971946ab9a9d644ddf7b26e9383d2391.tar.gz
gcc-d3c12306971946ab9a9d644ddf7b26e9383d2391.tar.bz2
Stack usage support
Stack usage support * common.opt (-fstack-usage): New option. * doc/invoke.texi (Debugging options): Document it. * builtins.c (expand_builtin_apply): Pass TRUE as 4th argument to allocate_dynamic_stack_space. (expand_builtin_alloca): Add 4th bool parameter CANNOT_ACCUMULATE and propagate it to allocate_dynamic_stack_space. (expand_builtin) <BUILT_IN_ALLOCA>: Adjust for above change. * calls.c (initialize_argument_information): Pass TRUE as 4th argument to allocate_dynamic_stack_space. (expand_call): Set current_function_has_unbounded_dynamic_stack_size to 1 when pushing a variable-sized argument onto the stack. Pass TRUE as 4th argument to allocate_dynamic_stack_space. Update current_function_pushed_stack_size. (emit_library_call_value_1): Likewise. * explow.c (allocate_dynamic_stack_space): Add 4th bool parameter CANNOT_ACCUMULATE. If flag_stack_usage, look into the size and attempt to find an upper bound. Remove redundant code for the SETJMP_VIA_SAVE_AREA case. * expr.h (allocate_dynamic_stack_space): Add 4th bool parameter. * function.h (struct stack_usage): New structure. (current_function_static_stack_size): New macro. (current_function_dynamic_stack_size): Likewise. (current_function_pushed_stack_size): Likewise. (current_function_dynamic_alloc_count): Likewise. (current_function_has_unbounded_dynamic_stack_size): Likewise. (current_function_allocates_dynamic_stack_space): Likewise. (struct function): Add new field 'su'. * function.c (instantiate_virtual_regs): If SETJMP_VIA_SAVE_AREA, add the value of the dynamic offset to the dynamic stack usage. (gimplify_parameters): Set ALLOCA_FOR_VAR_P on call to BUILT_IN_ALLOCA for variable-sized objects. (prepare_function_start): Allocate cfun->su if flag_stack_usage. (rest_of_handle_thread_prologue_and_epilogue): Call output_stack_usage. * gimplify.c (gimplify_decl_expr): Set ALLOCA_FOR_VAR_P on call to BUILT_IN_ALLOCA for variable-sized objects. * output.h (output_stack_usage): Declare. * toplev.c (stack_usage_file): New file pointer. (output_stack_usage): New function. (open_auxiliary_file): Likewise. (lang_dependent_init): Open file if flag_stack_usage is set. (finalize): Close file if stack_usage_file is not null. * tree.h (ALLOCA_FOR_VAR_P): New macro. * config/alpha/alpha.c (compute_frame_size): New function. (alpha_expand_prologue): Use it. (alpha_start_function): Likewise. (alpha_expand_epilogue): Likewise. Set stack usage info. * config/i386/i386.c (ix86_expand_prologue): Likewise. * config/ia64/ia64.c (ia64_expand_prologue): Likewise. * config/mips/mips.c (mips_expand_prologue): Likewise. * config/pa/pa.c (hppa_expand_prologue): Likewise. * config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise. * config/sparc/sparc.c (sparc_expand_prologue): Likewise. testsuite/ * lib/gcc-dg.exp (cleanup-stack-usage): New procedure. * lib/scanasm.exp (scan-stack-usage): Likewise. (scan-stack-usage-not): Likewise. * gcc.dg/stack-usage-1.c: New test. * gcc.target/i386/stack-usage-realign.c: Likewise. From-SVN: r163660
Diffstat (limited to 'gcc/config/alpha')
-rw-r--r--gcc/config/alpha/alpha.c80
1 files changed, 29 insertions, 51 deletions
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 1cfca58..3adc846 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -7763,6 +7763,30 @@ emit_frame_store (unsigned int regno, rtx base_reg,
emit_frame_store_1 (reg, base_reg, frame_bias, base_ofs, reg);
}
+/* Compute the frame size. SIZE is the size of the "naked" frame
+ and SA_SIZE is the size of the register save area. */
+
+static HOST_WIDE_INT
+compute_frame_size (HOST_WIDE_INT size, HOST_WIDE_INT sa_size)
+{
+ if (TARGET_ABI_OPEN_VMS)
+ return ALPHA_ROUND (sa_size
+ + (alpha_procedure_type == PT_STACK ? 8 : 0)
+ + size
+ + crtl->args.pretend_args_size);
+ else if (TARGET_ABI_UNICOSMK)
+ /* We have to allocate space for the DSIB if we generate a frame. */
+ return ALPHA_ROUND (sa_size
+ + (alpha_procedure_type == PT_STACK ? 48 : 0))
+ + ALPHA_ROUND (size
+ + crtl->outgoing_args_size);
+ else
+ return ALPHA_ROUND (crtl->outgoing_args_size)
+ + sa_size
+ + ALPHA_ROUND (size
+ + crtl->args.pretend_args_size);
+}
+
/* Write function prologue. */
/* On vms we have two kinds of functions:
@@ -7796,24 +7820,10 @@ alpha_expand_prologue (void)
int i;
sa_size = alpha_sa_size ();
+ frame_size = compute_frame_size (get_frame_size (), sa_size);
- frame_size = get_frame_size ();
- if (TARGET_ABI_OPEN_VMS)
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 8 : 0)
- + frame_size
- + crtl->args.pretend_args_size);
- else if (TARGET_ABI_UNICOSMK)
- /* We have to allocate space for the DSIB if we generate a frame. */
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 48 : 0))
- + ALPHA_ROUND (frame_size
- + crtl->outgoing_args_size);
- else
- frame_size = (ALPHA_ROUND (crtl->outgoing_args_size)
- + sa_size
- + ALPHA_ROUND (frame_size
- + crtl->args.pretend_args_size));
+ if (flag_stack_usage)
+ current_function_static_stack_size = frame_size;
if (TARGET_ABI_OPEN_VMS)
reg_offset = 8 + 8 * cfun->machine->uses_condition_handler;
@@ -8135,23 +8145,7 @@ alpha_start_function (FILE *file, const char *fnname,
alpha_fnname = fnname;
sa_size = alpha_sa_size ();
-
- frame_size = get_frame_size ();
- if (TARGET_ABI_OPEN_VMS)
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 8 : 0)
- + frame_size
- + crtl->args.pretend_args_size);
- else if (TARGET_ABI_UNICOSMK)
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 48 : 0))
- + ALPHA_ROUND (frame_size
- + crtl->outgoing_args_size);
- else
- frame_size = (ALPHA_ROUND (crtl->outgoing_args_size)
- + sa_size
- + ALPHA_ROUND (frame_size
- + crtl->args.pretend_args_size));
+ frame_size = compute_frame_size (get_frame_size (), sa_size);
if (TARGET_ABI_OPEN_VMS)
reg_offset = 8 + 8 * cfun->machine->uses_condition_handler;
@@ -8353,23 +8347,7 @@ alpha_expand_epilogue (void)
int i;
sa_size = alpha_sa_size ();
-
- frame_size = get_frame_size ();
- if (TARGET_ABI_OPEN_VMS)
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 8 : 0)
- + frame_size
- + crtl->args.pretend_args_size);
- else if (TARGET_ABI_UNICOSMK)
- frame_size = ALPHA_ROUND (sa_size
- + (alpha_procedure_type == PT_STACK ? 48 : 0))
- + ALPHA_ROUND (frame_size
- + crtl->outgoing_args_size);
- else
- frame_size = (ALPHA_ROUND (crtl->outgoing_args_size)
- + sa_size
- + ALPHA_ROUND (frame_size
- + crtl->args.pretend_args_size));
+ frame_size = compute_frame_size (get_frame_size (), sa_size);
if (TARGET_ABI_OPEN_VMS)
{