diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-10-21 16:55:38 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-10-21 16:55:38 +0000 |
commit | 3edf64aa919b9bf725672bd0ad91bfd30c6a31df (patch) | |
tree | c3163bb97d62851d6b1e3f51f6a8d28cd498be0b /gcc/ipa-pure-const.c | |
parent | 50684f95305bc5e6dcab6533e330d66e7ec975fc (diff) | |
download | gcc-3edf64aa919b9bf725672bd0ad91bfd30c6a31df.zip gcc-3edf64aa919b9bf725672bd0ad91bfd30c6a31df.tar.gz gcc-3edf64aa919b9bf725672bd0ad91bfd30c6a31df.tar.bz2 |
State cleanups from jit branch
gcc/ChangeLog:
* cgraph.c (cgraph_c_finalize): New function.
* cgraph.h (cgraph_c_finalize): New prototype.
(cgraphunit_c_finalize): New prototype.
* cgraphunit.c (first_analyzed): Move from analyze_functions
to file-scope.
(first_analyzed_var): Likewise.
(analyze_functions): Move static variables into file-scope.
(cgraphunit_c_finalize): New function.
* diagnostic.c (diagnostic_finish): Free the memory for
context->classify_diagnostic and context->printer, running the
destructor for the latter.
(bt_stop): Use toplev::main.
* dwarf2out.c (dwarf2out_finalize): New function.
* dwarf2out.h (dwarf2out_c_finalize): New prototype.
* gcse.c (gcse_c_finalize): New function.
* gcse.h (gcse_c_finalize): New prototype.
* ggc-page.c (init_ggc): Make idempotent.
* input.c (input_location): Initialize to UNKNOWN_LOCATION.
* ipa-cp.c (ipa_cp_c_finalize): New function.
* ipa-prop.h (ipa_cp_c_finalize): New prototype.
* ipa-pure-const.c (function_insertion_hook_holder): Move to be
a field of class pass_ipa_pure_const.
(node_duplication_hook_holder): Likewise.
(node_removal_hook_holder): Likewise.
(register_hooks): Convert to method...
(pass_ipa_pure_const::register_hooks): ...here, converting
static variable init_p into...
(pass_ipa_pure_const::init_p): ...new field.
(pure_const_generate_summary): Update invocation of
register_hooks to invoke as a method of current_pass.
(pure_const_read_summary): Likewise.
(propagate): Convert to...
(pass_ipa_pure_const::execute): ...method.
* ipa-reference.c (ipa_init): Move static bool init_p from here
to...
(ipa_init_p): New file-scope variable, so that it can be reset
when repeatedly invoking the compiler within one process by...
(ipa_reference_c_finalize): New function.
* ipa-reference.h (ipa_reference_c_finalize): New.
* main.c (main): Replace invocation of toplev_main with
construction of a toplev instance, and call its "main" method.
* params.c (global_init_params): Add an assert that
params_finished is false.
(params_c_finalize): New.
* params.h (params_c_finalize): New.
* passes.c (execute_ipa_summary_passes): Set "current_pass" before
invoking generate_summary, for the benefit of pass_ipa_pure_const.
(ipa_write_summaries_2): Assign "pass" to "current_pass" global
before calling write_summary hook.
(ipa_write_optimization_summaries_1): Likewise when calling
write_optimization_summary hook.
(ipa_read_summaries_1): Likewise for read_summary hook.
(ipa_read_optimization_summaries_1): Likewise for
read_optimization_summary hook.
(execute_ipa_stmt_fixups): Likewise.
* stringpool.c (init_stringpool): Clean up if we're called more
than once.
* timevar.c (timevar_init): Ignore repeated calls.
* toplev.c: Include "dwarf2out.h", "ipa-reference.h", "gcse.h",
"ipa-prop.h".
(general_init): Reset "input_location" to UNKNOWN_LOCATION.
(initialize_rtl): Move static local "initialized_once"
into file scope, and rename to...
(rtl_initialized): New variable.
(do_compile): Move timevar initialization from here to
toplev::start_timevars.
(toplev::toplev, toplev::~toplev, toplev::start_timevars,
toplev::finalize): New functions.
(toplev_main): Rename to...
(toplev::main): ...this.
* toplev.h (class toplev): New class.
From-SVN: r216522
Diffstat (limited to 'gcc/ipa-pure-const.c')
-rw-r--r-- | gcc/ipa-pure-const.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index b5ded3e..c221cd0 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -115,10 +115,45 @@ typedef struct funct_state_d * funct_state; static vec<funct_state> funct_state_vec; -/* Holders of ipa cgraph hooks: */ -static struct cgraph_node_hook_list *function_insertion_hook_holder; -static struct cgraph_2node_hook_list *node_duplication_hook_holder; -static struct cgraph_node_hook_list *node_removal_hook_holder; +static bool gate_pure_const (void); + +namespace { + +const pass_data pass_data_ipa_pure_const = +{ + IPA_PASS, /* type */ + "pure-const", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_IPA_PURE_CONST, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_ipa_pure_const : public ipa_opt_pass_d +{ +public: + pass_ipa_pure_const(gcc::context *ctxt); + + /* opt_pass methods: */ + bool gate (function *) { return gate_pure_const (); } + unsigned int execute (function *fun); + + void register_hooks (void); + +private: + bool init_p; + + /* Holders of ipa cgraph hooks: */ + struct cgraph_node_hook_list *function_insertion_hook_holder; + struct cgraph_2node_hook_list *node_duplication_hook_holder; + struct cgraph_node_hook_list *node_removal_hook_holder; + +}; // class pass_ipa_pure_const + +} // anon namespace /* Try to guess if function body will always be visible to compiler when compiling the call and whether compiler will be able @@ -881,11 +916,10 @@ remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) } -static void +void +pass_ipa_pure_const:: register_hooks (void) { - static bool init_p = false; - if (init_p) return; @@ -908,7 +942,8 @@ pure_const_generate_summary (void) { struct cgraph_node *node; - register_hooks (); + pass_ipa_pure_const *pass = static_cast <pass_ipa_pure_const *> (current_pass); + pass->register_hooks (); /* Process all of the functions. @@ -989,7 +1024,9 @@ pure_const_read_summary (void) struct lto_file_decl_data *file_data; unsigned int j = 0; - register_hooks (); + pass_ipa_pure_const *pass = static_cast <pass_ipa_pure_const *> (current_pass); + pass->register_hooks (); + while ((file_data = file_data_vec[j++])) { const char *data; @@ -1470,8 +1507,9 @@ propagate_nothrow (void) /* Produce the global information by preforming a transitive closure on the local information that was produced by generate_summary. */ -static unsigned int -propagate (void) +unsigned int +pass_ipa_pure_const:: +execute (function *) { struct cgraph_node *node; @@ -1500,44 +1538,23 @@ gate_pure_const (void) && !seen_error ()); } -namespace { - -const pass_data pass_data_ipa_pure_const = +pass_ipa_pure_const::pass_ipa_pure_const(gcc::context *ctxt) + : ipa_opt_pass_d(pass_data_ipa_pure_const, ctxt, + pure_const_generate_summary, /* generate_summary */ + pure_const_write_summary, /* write_summary */ + pure_const_read_summary, /* read_summary */ + NULL, /* write_optimization_summary */ + NULL, /* read_optimization_summary */ + NULL, /* stmt_fixup */ + 0, /* function_transform_todo_flags_start */ + NULL, /* function_transform */ + NULL), /* variable_transform */ + init_p(false), + function_insertion_hook_holder(NULL), + node_duplication_hook_holder(NULL), + node_removal_hook_holder(NULL) { - IPA_PASS, /* type */ - "pure-const", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_IPA_PURE_CONST, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ -}; - -class pass_ipa_pure_const : public ipa_opt_pass_d -{ -public: - pass_ipa_pure_const (gcc::context *ctxt) - : ipa_opt_pass_d (pass_data_ipa_pure_const, ctxt, - pure_const_generate_summary, /* generate_summary */ - pure_const_write_summary, /* write_summary */ - pure_const_read_summary, /* read_summary */ - NULL, /* write_optimization_summary */ - NULL, /* read_optimization_summary */ - NULL, /* stmt_fixup */ - 0, /* function_transform_todo_flags_start */ - NULL, /* function_transform */ - NULL) /* variable_transform */ - {} - - /* opt_pass methods: */ - virtual bool gate (function *) { return gate_pure_const (); } - virtual unsigned int execute (function *) { return propagate (); } - -}; // class pass_ipa_pure_const - -} // anon namespace +} ipa_opt_pass_d * make_pass_ipa_pure_const (gcc::context *ctxt) |