Mercurial > hg > CbC > CbC_gcc
diff gcc/passes.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | d34655255c78 1830386684a0 |
line wrap: on
line diff
--- a/gcc/passes.c Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/passes.c Thu Oct 25 07:37:49 2018 +0900 @@ -1,5 +1,5 @@ /* Top level of GCC compilers (cc1, cc1plus, etc.) - Copyright (C) 1987-2017 Free Software Foundation, Inc. + Copyright (C) 1987-2018 Free Software Foundation, Inc. This file is part of GCC. @@ -117,8 +117,6 @@ pass_manager::execute_early_local_passes () { execute_pass_list (cfun, pass_build_ssa_passes_1->sub); - if (flag_check_pointer_bounds) - execute_pass_list (cfun, pass_chkp_instrumentation_passes_1->sub); execute_pass_list (cfun, pass_local_optimization_passes_1->sub); } @@ -432,36 +430,6 @@ }; // class pass_build_ssa_passes -const pass_data pass_data_chkp_instrumentation_passes = -{ - SIMPLE_IPA_PASS, /* type */ - "chkp_passes", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ -}; - -class pass_chkp_instrumentation_passes : public simple_ipa_opt_pass -{ -public: - pass_chkp_instrumentation_passes (gcc::context *ctxt) - : simple_ipa_opt_pass (pass_data_chkp_instrumentation_passes, ctxt) - {} - - /* opt_pass methods: */ - virtual bool gate (function *) - { - /* Don't bother doing anything if the program has errors. */ - return (flag_check_pointer_bounds - && !seen_error () && !in_lto_p); - } - -}; // class pass_chkp_instrumentation_passes - const pass_data pass_data_local_optimization_passes = { SIMPLE_IPA_PASS, /* type */ @@ -500,12 +468,6 @@ } simple_ipa_opt_pass * -make_pass_chkp_instrumentation_passes (gcc::context *ctxt) -{ - return new pass_chkp_instrumentation_passes (ctxt); -} - -simple_ipa_opt_pass * make_pass_local_optimization_passes (gcc::context *ctxt) { return new pass_local_optimization_passes (ctxt); @@ -784,7 +746,7 @@ char num[11]; dump_kind dkind; int id; - int optgroup_flags = OPTGROUP_NONE; + optgroup_flags_t optgroup_flags = OPTGROUP_NONE; gcc::dump_manager *dumps = m_ctxt->get_dumps (); /* See below in next_pass_1. */ @@ -1208,7 +1170,7 @@ if (!slot) return false; - cgraph_uid = func ? cgraph_node::get (func)->uid : 0; + cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0; if (func && DECL_ASSEMBLER_NAME_SET_P (func)) aname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func)); @@ -1442,7 +1404,6 @@ pass_manager::register_pass (struct register_pass_info *pass_info) { bool all_instances, success; - gcc::dump_manager *dumps = m_ctxt->get_dumps (); /* The checks below could fail in buggy plugins. Existing GCC passes should never fail these checks, so we mention plugin in @@ -1480,33 +1441,16 @@ /* OK, we have successfully inserted the new pass. We need to register the dump files for the newly added pass and its duplicates (if any). - Because the registration of plugin/backend passes happens after the - command-line options are parsed, the options that specify single - pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new - passes. Therefore we currently can only enable dumping of - new passes when the 'dump-all' flags (e.g. -fdump-tree-all) - are specified. While doing so, we also delete the pass_list_node + While doing so, we also delete the pass_list_node objects created during pass positioning. */ + gcc::dump_manager *dumps = m_ctxt->get_dumps (); while (added_pass_nodes) { struct pass_list_node *next_node = added_pass_nodes->next; - enum tree_dump_index tdi; - register_one_dump_file (added_pass_nodes->pass); - if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS - || added_pass_nodes->pass->type == IPA_PASS) - tdi = TDI_ipa_all; - else if (added_pass_nodes->pass->type == GIMPLE_PASS) - tdi = TDI_tree_all; - else - tdi = TDI_rtl_all; - /* Check if dump-all flag is specified. */ - if (dumps->get_dump_file_info (tdi)->pstate) - { - dumps->get_dump_file_info (added_pass_nodes->pass->static_pass_number) - ->pstate = dumps->get_dump_file_info (tdi)->pstate; - dumps->get_dump_file_info (added_pass_nodes->pass->static_pass_number) - ->pflags = dumps->get_dump_file_info (tdi)->pflags; - } + + /* Handle -fdump-* and -fopt-info. */ + dumps->register_pass (added_pass_nodes->pass); + XDELETE (added_pass_nodes); added_pass_nodes = next_node; } @@ -1584,7 +1528,7 @@ #define NEXT_PASS(PASS, NUM) \ do { \ - gcc_assert (NULL == PASS ## _ ## NUM); \ + gcc_assert (PASS ## _ ## NUM == NULL); \ if ((NUM) == 1) \ PASS ## _1 = make_##PASS (m_ctxt); \ else \ @@ -1673,22 +1617,16 @@ static int nnodes; static GTY ((length ("nnodes"))) cgraph_node **order; +#define uid_hash_t hash_set<int_hash <int, 0, -1> > + /* Hook called when NODE is removed and therefore should be - excluded from order vector. DATA is an array of integers. - DATA[0] holds max index it may be accessed by. For cgraph - node DATA[node->uid + 1] holds index of this node in order - vector. */ + excluded from order vector. DATA is a hash set with removed nodes. */ + static void remove_cgraph_node_from_order (cgraph_node *node, void *data) { - int *order_idx = (int *)data; - - if (node->uid >= order_idx[0]) - return; - - int idx = order_idx[node->uid + 1]; - if (idx >= 0 && idx < nnodes && order[idx] == node) - order[idx] = NULL; + uid_hash_t *removed_nodes = (uid_hash_t *)data; + removed_nodes->add (node->get_uid ()); } /* If we are in IPA mode (i.e., current_function_decl is NULL), call @@ -1705,30 +1643,23 @@ else { cgraph_node_hook_list *hook; - int *order_idx; + uid_hash_t removed_nodes; gcc_assert (!order); order = ggc_vec_alloc<cgraph_node *> (symtab->cgraph_count); - order_idx = XALLOCAVEC (int, symtab->cgraph_max_uid + 1); - memset (order_idx + 1, -1, sizeof (int) * symtab->cgraph_max_uid); - order_idx[0] = symtab->cgraph_max_uid; - nnodes = ipa_reverse_postorder (order); for (i = nnodes - 1; i >= 0; i--) - { - order[i]->process = 1; - order_idx[order[i]->uid + 1] = i; - } + order[i]->process = 1; hook = symtab->add_cgraph_removal_hook (remove_cgraph_node_from_order, - order_idx); + &removed_nodes); for (i = nnodes - 1; i >= 0; i--) { + cgraph_node *node = order[i]; + /* Function could be inlined and removed as unreachable. */ - if (!order[i]) + if (node == NULL || removed_nodes.contains (node->get_uid ())) continue; - struct cgraph_node *node = order[i]; - /* Allow possibly removed nodes to be garbage collected. */ order[i] = NULL; node->process = 0; @@ -2692,6 +2623,9 @@ if ((!flag_generate_lto && !flag_generate_offload) || seen_error ()) return; + gcc_assert (!dump_file); + streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL); + select_what_to_stream (); encoder = lto_symtab_encoder_new (false); @@ -2708,7 +2642,7 @@ { struct cgraph_node *node = order[i]; - if (node->has_gimple_body_p ()) + if (gimple_has_body_p (node->decl)) { /* When streaming out references to statements as part of some IPA pass summary, the statements need to have uids assigned and the @@ -2734,6 +2668,11 @@ ipa_write_summaries_1 (compute_ltrans_boundary (encoder)); free (order); + if (streamer_dump_file) + { + dump_end (TDI_lto_stream_out, streamer_dump_file); + streamer_dump_file = NULL; + } } /* Same as execute_pass_list but assume that subpasses of IPA passes