From: Alexander Monakov Date: Wed, 31 May 2017 13:26:54 +0000 (+0300) Subject: passes.c: implement pre-ICE emergency dumping X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a02d1ad2b2973bcc047715b39df2ff1c69385541;p=gcc.git passes.c: implement pre-ICE emergency dumping * passes.c (emergency_dump_function): New. * tree-pass.h (emergency_dump_function): Declare. * plugin.c (plugins_internal_error_function): Remove. * plugin.h (plugins_internal_error_function): Remove declaration. * toplev.c (internal_error_function): New static function. Use it... (general_init): ...here. From-SVN: r248736 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f42b287413b..9c7b3de1dd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-05-31 Alexander Monakov + + * passes.c (emergency_dump_function): New. + * tree-pass.h (emergency_dump_function): Declare. + * plugin.c (plugins_internal_error_function): Remove. + * plugin.h (plugins_internal_error_function): Remove declaration. + * toplev.c (internal_error_function): New static function. Use it... + (general_init): ...here. + 2017-05-31 Graham Markall * config/arc/arc.c (arc_print_operand): Handle constant operands. diff --git a/gcc/passes.c b/gcc/passes.c index 98e05e4ba7a..64493ba1688 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-live.h" /* For remove_unused_locals. */ #include "tree-cfgcleanup.h" #include "insn-addr.h" /* for INSN_ADDRESSES_ALLOC. */ +#include "diagnostic-core.h" /* for fnotice */ using namespace gcc; @@ -1779,6 +1780,24 @@ execute_function_dump (function *fn, void *data) } } +/* This function is called when an internal compiler error is encountered. + Ensure that function dump is made available before compiler is aborted. */ + +void +emergency_dump_function () +{ + if (!current_pass) + return; + enum opt_pass_type pt = current_pass->type; + fnotice (stderr, "during %s pass: %s\n", + pt == GIMPLE_PASS ? "GIMPLE" : pt == RTL_PASS ? "RTL" : "IPA", + current_pass->name); + if (!dump_file || !cfun) + return; + fnotice (stderr, "dump file: %s\n", dump_file_name); + execute_function_dump (cfun, current_pass); +} + static struct profile_record *profile_record; /* Do profile consistency book-keeping for the pass with static number INDEX. diff --git a/gcc/plugin.c b/gcc/plugin.c index c6d3cddd810..9892748cd15 100644 --- a/gcc/plugin.c +++ b/gcc/plugin.c @@ -858,16 +858,6 @@ warn_if_plugins (void) } -/* Likewise, as a callback from the diagnostics code. */ - -void -plugins_internal_error_function (diagnostic_context *context ATTRIBUTE_UNUSED, - const char *msgid ATTRIBUTE_UNUSED, - va_list *ap ATTRIBUTE_UNUSED) -{ - warn_if_plugins (); -} - /* The default version check. Compares every field in VERSION. */ bool diff --git a/gcc/plugin.h b/gcc/plugin.h index 68a673b40d9..b96445d0a33 100644 --- a/gcc/plugin.h +++ b/gcc/plugin.h @@ -167,8 +167,6 @@ extern bool plugins_active_p (void); extern void dump_active_plugins (FILE *); extern void debug_active_plugins (void); extern void warn_if_plugins (void); -extern void plugins_internal_error_function (diagnostic_context *, - const char *, va_list *); extern void print_plugins_versions (FILE *file, const char *indent); extern void print_plugins_help (FILE *file, const char *indent); extern void finalize_plugins (void); diff --git a/gcc/toplev.c b/gcc/toplev.c index 425315c8b5e..f8b5a4001c4 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -79,6 +79,7 @@ along with GCC; see the file COPYING3. If not see #include "omp-offload.h" #include "hsa-common.h" #include "edit-context.h" +#include "tree-pass.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -1063,6 +1064,15 @@ open_auxiliary_file (const char *ext) return file; } +/* Auxiliary callback for the diagnostics code. */ + +static void +internal_error_function (diagnostic_context *, const char *, va_list *) +{ + warn_if_plugins (); + emergency_dump_function (); +} + /* Initialization of the front end environment, before command line options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ @@ -1101,7 +1111,7 @@ general_init (const char *argv0, bool init_signals) = global_options_init.x_flag_diagnostics_show_option; global_dc->show_column = global_options_init.x_flag_show_column; - global_dc->internal_error = plugins_internal_error_function; + global_dc->internal_error = internal_error_function; global_dc->option_enabled = option_enabled; global_dc->option_state = &global_options; global_dc->option_name = option_name; diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index cfa4b01f81a..0f7d936e64b 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -634,6 +634,7 @@ extern void execute_all_ipa_transforms (void); extern void execute_all_ipa_stmt_fixups (struct cgraph_node *, gimple **); extern bool pass_init_dump_file (opt_pass *); extern void pass_fini_dump_file (opt_pass *); +extern void emergency_dump_function (void); extern void print_current_pass (FILE *); extern void debug_pass (void);