diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2011-05-25 11:00:14 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2011-05-25 11:00:14 +0000 |
commit | a11e0df4da7c987c9627724748fe727183e9379f (patch) | |
tree | 8f263f60484dabe77a13c389e9ce210b121dbc56 /gcc/toplev.c | |
parent | e7cfe2413fe50e22eb2c013415cec9e154d3c391 (diff) | |
download | gcc-a11e0df4da7c987c9627724748fe727183e9379f.zip gcc-a11e0df4da7c987c9627724748fe727183e9379f.tar.gz gcc-a11e0df4da7c987c9627724748fe727183e9379f.tar.bz2 |
common.opt (flag_stack_usage_info): New variable.
* common.opt (flag_stack_usage_info): New variable.
(-Wstack-usage): New option.
* doc/invoke.texi (Warning options): Document -Wstack-usage.
* opts.c (common_handle_option) <OPT_Wstack_usage_>: New case.
<OPT_fstack_usage>: Likewise.
* toplev.c (output_stack_usage): Handle -Wstack-usage.
* calls.c (expand_call): Test flag_stack_usage_info variable instead
of flag_stack_usage.
(emit_library_call_value_1): Likewise.
* explow.c (allocate_dynamic_stack_space): Likewise.
* function.c (instantiate_virtual_regs ): Likewise.
(prepare_function_start): Likewise.
(rest_of_handle_thread_prologue_and_epilogue): Likewise.
* config/alpha/alpha.c (alpha_expand_prologue): Likewise.
* config/arm/arm.c (arm_expand_prologue): Likewise.
(thumb1_expand_prologue): Likewise.
* config/avr/avr.c (expand_prologue): Likewise.
* config/i386/i386.c (ix86_expand_prologue): Likewise.
* config/ia64/ia64.c (ia64_expand_prologue): Likewise.
* config/m68k/m68k.c (m68k_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/s390/s390.c (s390_emit_prologue): Likewise.
* config/sh/sh.c (sh_expand_prologue): Likewise.
* config/sparc/sparc.c (sparc_expand_prologue): Likewise.
* config/spu/spu.c (spu_expand_prologue): Likewise.
From-SVN: r174182
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index d002427..6c992cf 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1048,14 +1048,12 @@ output_stack_usage (void) }; HOST_WIDE_INT stack_usage = current_function_static_stack_size; enum stack_usage_kind_type stack_usage_kind; - expanded_location loc; - const char *raw_id, *id; if (stack_usage < 0) { if (!warning_issued) { - warning (0, "-fstack-usage not supported for this target"); + warning (0, "stack usage computation not supported for this target"); warning_issued = true; } return; @@ -1082,24 +1080,44 @@ output_stack_usage (void) stack_usage += current_function_dynamic_stack_size; } - loc = expand_location (DECL_SOURCE_LOCATION (current_function_decl)); + if (flag_stack_usage) + { + expanded_location loc + = expand_location (DECL_SOURCE_LOCATION (current_function_decl)); + const char *raw_id, *id; + + /* Strip the scope prefix if any. */ + raw_id = lang_hooks.decl_printable_name (current_function_decl, 2); + id = strrchr (raw_id, '.'); + if (id) + id++; + else + id = raw_id; + + fprintf (stack_usage_file, + "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n", + lbasename (loc.file), + loc.line, + loc.column, + id, + stack_usage, + stack_usage_kind_str[stack_usage_kind]); + } - /* Strip the scope prefix if any. */ - raw_id = lang_hooks.decl_printable_name (current_function_decl, 2); - id = strrchr (raw_id, '.'); - if (id) - id++; - else - id = raw_id; - - fprintf (stack_usage_file, - "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n", - lbasename (loc.file), - loc.line, - loc.column, - id, - stack_usage, - stack_usage_kind_str[stack_usage_kind]); + if (warn_stack_usage >= 0) + { + if (stack_usage_kind == DYNAMIC) + warning (OPT_Wstack_usage_, "stack usage might be unbounded"); + else if (stack_usage > warn_stack_usage) + { + if (stack_usage_kind == DYNAMIC_BOUNDED) + warning (OPT_Wstack_usage_, "stack usage might be %wd bytes", + stack_usage); + else + warning (OPT_Wstack_usage_, "stack usage is %wd bytes", + stack_usage); + } + } } /* Open an auxiliary output file. */ |