From 20dc3373f08fa192027506461c62dc8cf8a85c0d Mon Sep 17 00:00:00 2001 From: vries Date: Wed, 15 Apr 2015 18:43:32 +0000 Subject: [PATCH] Fix fdump-passes 2015-04-15 Tom de Vries PR other/65487 * function.c (push_dummy_function): New function. (init_dummy_function_start): Use push_dummy_function. (pop_dummy_function): New function. Factored out of ... (expand_dummy_function_end): ... here. * function.h (push_dummy_function, pop_dummy_function): Declare. * passes.c (pass_manager::dump_passes): Use push_dummy_function and pop_dummy_function. * tree-chkp.c (chkp_gate): Handle cgraph_node::get (cfun->decl) == NULL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222129 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 ++++++++++++ gcc/function.c | 37 ++++++++++++++++++++++++++++++++----- gcc/function.h | 2 ++ gcc/passes.c | 17 ++--------------- gcc/tree-chkp.c | 6 ++++-- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0f2fe7e2b9..6fc26196636 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2015-04-15 Tom de Vries + + PR other/65487 + * function.c (push_dummy_function): New function. + (init_dummy_function_start): Use push_dummy_function. + (pop_dummy_function): New function. Factored out of ... + (expand_dummy_function_end): ... here. + * function.h (push_dummy_function, pop_dummy_function): Declare. + * passes.c (pass_manager::dump_passes): Use push_dummy_function and + pop_dummy_function. + * tree-chkp.c (chkp_gate): Handle cgraph_node::get (cfun->decl) == NULL. + 2015-04-15 Jeff Law PR rtl-optimization/42522 diff --git a/gcc/function.c b/gcc/function.c index cb974bfe83d..7d4df92f40e 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4862,6 +4862,29 @@ prepare_function_start (void) frame_pointer_needed = 0; } +void +push_dummy_function (bool with_decl) +{ + tree fn_decl, fn_type, fn_result_decl; + + gcc_assert (!in_dummy_function); + in_dummy_function = true; + + if (with_decl) + { + fn_type = build_function_type_list (void_type_node, NULL_TREE); + fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, NULL_TREE, + fn_type); + fn_result_decl = build_decl (UNKNOWN_LOCATION, RESULT_DECL, + NULL_TREE, void_type_node); + DECL_RESULT (fn_decl) = fn_result_decl; + } + else + fn_decl = NULL_TREE; + + push_struct_function (fn_decl); +} + /* Initialize the rtl expansion mechanism so that we can do simple things like generate sequences. This is used to provide a context during global initialization of some passes. You must call expand_dummy_function_end @@ -4870,9 +4893,7 @@ prepare_function_start (void) void init_dummy_function_start (void) { - gcc_assert (!in_dummy_function); - in_dummy_function = true; - push_struct_function (NULL_TREE); + push_dummy_function (false); prepare_function_start (); } @@ -5144,6 +5165,13 @@ expand_function_start (tree subr) stack_check_probe_note = emit_note (NOTE_INSN_DELETED); } +void +pop_dummy_function (void) +{ + pop_cfun (); + in_dummy_function = false; +} + /* Undo the effects of init_dummy_function_start. */ void expand_dummy_function_end (void) @@ -5159,8 +5187,7 @@ expand_dummy_function_end (void) free_after_parsing (cfun); free_after_compilation (cfun); - pop_cfun (); - in_dummy_function = false; + pop_dummy_function (); } /* Helper for diddle_return_value. */ diff --git a/gcc/function.h b/gcc/function.h index 363d666d52f..fc12f264621 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -896,6 +896,8 @@ extern int get_next_funcdef_no (void); extern int get_last_funcdef_no (void); extern void allocate_struct_function (tree, bool); extern void push_struct_function (tree fndecl); +extern void push_dummy_function (bool); +extern void pop_dummy_function (void); extern void init_dummy_function_start (void); extern void init_function_start (tree); extern void stack_protect_epilogue (void); diff --git a/gcc/passes.c b/gcc/passes.c index beffd3f587a..04ff04247ad 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -946,32 +946,19 @@ dump_passes (void) void pass_manager::dump_passes () const { - struct cgraph_node *n, *node = NULL; + push_dummy_function (true); create_pass_tab (); - FOR_EACH_FUNCTION (n) - if (DECL_STRUCT_FUNCTION (n->decl)) - { - node = n; - break; - } - - if (!node) - return; - - push_cfun (DECL_STRUCT_FUNCTION (node->decl)); - dump_pass_list (all_lowering_passes, 1); dump_pass_list (all_small_ipa_passes, 1); dump_pass_list (all_regular_ipa_passes, 1); dump_pass_list (all_late_ipa_passes, 1); dump_pass_list (all_passes, 1); - pop_cfun (); + pop_dummy_function (); } - /* Returns the pass with NAME. */ static opt_pass * diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 8c5a628a9ad..ebb9a836e5e 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -4330,8 +4330,10 @@ chkp_execute (void) static bool chkp_gate (void) { - return cgraph_node::get (cfun->decl)->instrumentation_clone - || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl)); + cgraph_node *node = cgraph_node::get (cfun->decl); + return ((node != NULL + && node->instrumentation_clone) + || lookup_attribute ("chkp ctor", DECL_ATTRIBUTES (cfun->decl))); } namespace { -- 2.11.4.GIT