[PATCH] Implement -fstack-usage
Eric Botcazou
ebotcazou@adacore.com
Mon Jun 19 13:49:00 GMT 2006
Hi,
While we are at it, here is another patch whose submission was delayed because
of the already substantial backlog of AdaCore patches. This is related to
http://www.gccsummit.org/2005/view_abstract.php?content_key=18
Tested on i586-suse-linux.
2006-06-19 Eric Botcazou <ebotcazou@adacore.com>
Stack usage support
* common.opt (-fstack-usage): New option.
* doc/invoke.texi (Debugging options): Document it.
* expr.h (allocate_dynamic_stack_space): Add 4th bool parameter.
* 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.
* flow.c (rest_of_handle_flow2): Invoke output_stack_usage if needed.
* function.h (struct function): Add new fields pushed_stack_size,
dynamic_alloc_count, dynamic_stack_size and
has_unbounded_dynamic_stack_size.
(current_function_pushed_stack_size): New macro.
(current_function_dynamic_alloc_count): Likewise.
(current_function_dynamic_stack_size): Likewise.
(current_function_has_unbounded_dynamic_stack_size): Likewise.
(current_function_allocates_dynamic_stack_space): Likewise.
* function.c (instantiate_virtual_regs): If SETJMP_VIA_SAVE_AREA,
add the value of the dynamic offset to the dynamic stack usage.
* gimplify.c (gimplify_decl_expr): Set CALL_FROM_THUNK_P on the call
to BUILT_IN_ALLOCA for variable-sized objects.
* stmt.c (expand_decl): Pass true to allocate_dynamic_stack_space.
* toplev.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 (CALL_FROM_THUNK_P): Document specialized usage.
* target.h (struct gcc_target): Add get_static_stack_usage.
* target-def.h (TARGET_GET_STATIC_STACK_USAGE): Define to 0.
(TARGET_INITIALIZER): Add it.
* doc/tm.texi (Frame layout): Document it.
* config/alpha/alpha.c (compute_frame_size): New function.
(alpha_expand_prologue): Use it.
(alpha_start_function): Likewise.
(alpha_expand_epilogue): Likewise.
(alpha_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/i386/i386.c (ix86_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/ia64/ia64.c (ia64_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/mips/mips.c (mips_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/pa/pa.c (pa_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/rs6000/rs6000.c (rs6000_get_static_stack_usage): New.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
* config/sparc/sparc.c (sparc_get_static_stack_usage): New function.
(TARGET_GET_STATIC_STACK_USAGE): Define to it.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f506-002-2_fsf.diff
Type: text/x-diff
Size: 40484 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060619/47f04ff9/attachment.bin>
More information about the Gcc-patches
mailing list