1 /* Top-level control of tree optimizations.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
27 #include "basic-block.h"
31 #include "langhooks.h"
32 #include "diagnostic-core.h"
36 #include "tree-inline.h"
37 #include "tree-pass.h"
45 /* Pass: cleanup the CFG just before expanding trees to RTL.
46 This is just a round of label cleanups and case node grouping
47 because after the tree optimizers have run such cleanups may
51 execute_cleanup_cfg_post_optimizing (void)
53 unsigned int todo
= 0;
54 if (cleanup_tree_cfg ())
55 todo
|= TODO_update_ssa
;
56 maybe_remove_unreachable_handlers ();
57 cleanup_dead_labels ();
59 if ((flag_compare_debug_opt
|| flag_compare_debug
)
60 && flag_dump_final_insns
)
62 FILE *final_output
= fopen (flag_dump_final_insns
, "a");
66 error ("could not open final insn dump file %qs: %m",
67 flag_dump_final_insns
);
68 flag_dump_final_insns
= NULL
;
72 int save_unnumbered
= flag_dump_unnumbered
;
73 int save_noaddr
= flag_dump_noaddr
;
75 flag_dump_noaddr
= flag_dump_unnumbered
= 1;
76 fprintf (final_output
, "\n");
77 dump_enumerated_decls (final_output
, dump_flags
| TDF_NOUID
);
78 flag_dump_noaddr
= save_noaddr
;
79 flag_dump_unnumbered
= save_unnumbered
;
80 if (fclose (final_output
))
82 error ("could not close final insn dump file %qs: %m",
83 flag_dump_final_insns
);
84 flag_dump_final_insns
= NULL
;
93 const pass_data pass_data_cleanup_cfg_post_optimizing
=
95 GIMPLE_PASS
, /* type */
96 "optimized", /* name */
97 OPTGROUP_NONE
, /* optinfo_flags */
99 true, /* has_execute */
100 TV_TREE_CLEANUP_CFG
, /* tv_id */
101 PROP_cfg
, /* properties_required */
102 0, /* properties_provided */
103 0, /* properties_destroyed */
104 0, /* todo_flags_start */
105 TODO_remove_unused_locals
, /* todo_flags_finish */
108 class pass_cleanup_cfg_post_optimizing
: public gimple_opt_pass
111 pass_cleanup_cfg_post_optimizing (gcc::context
*ctxt
)
112 : gimple_opt_pass (pass_data_cleanup_cfg_post_optimizing
, ctxt
)
115 /* opt_pass methods: */
116 unsigned int execute () {
117 return execute_cleanup_cfg_post_optimizing ();
120 }; // class pass_cleanup_cfg_post_optimizing
125 make_pass_cleanup_cfg_post_optimizing (gcc::context
*ctxt
)
127 return new pass_cleanup_cfg_post_optimizing (ctxt
);