aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index fde14d1..b13e580 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -63,6 +63,7 @@ Boston, MA 02111-1307, USA. */
#include "regs.h"
#include "timevar.h"
#include "diagnostic.h"
+#include "ssa.h"
#ifndef ACCUMULATE_OUTGOING_ARGS
#define ACCUMULATE_OUTGOING_ARGS 0
@@ -259,6 +260,7 @@ enum dump_file_index
DFI_cse,
DFI_addressof,
DFI_ssa,
+ DFI_dce,
DFI_ussa,
DFI_gcse,
DFI_loop,
@@ -291,7 +293,7 @@ enum dump_file_index
Remaining -d letters:
" h o q u "
- " H K OPQ TUVWXYZ"
+ " H K OPQ TUVW YZ"
*/
struct dump_file_info dump_file[DFI_MAX] =
@@ -302,6 +304,7 @@ struct dump_file_info dump_file[DFI_MAX] =
{ "cse", 's', 0, 0, 0 },
{ "addressof", 'F', 0, 0, 0 },
{ "ssa", 'e', 1, 0, 0 },
+ { "dce", 'X', 1, 0, 0 },
{ "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
{ "gcse", 'G', 1, 0, 0 },
{ "loop", 'L', 1, 0, 0 },
@@ -786,6 +789,9 @@ int flag_gnu_linker = 1;
/* Enable SSA. */
int flag_ssa = 0;
+/* Enable dead code elimination. */
+int flag_dce = 0;
+
/* Tag all structures with __attribute__(packed) */
int flag_pack_struct = 0;
@@ -1094,6 +1100,8 @@ lang_independent_options f_options[] =
"Instrument function entry/exit with profiling calls"},
{"ssa", &flag_ssa, 1,
"Enable SSA optimizations" },
+ {"dce", &flag_dce, 1,
+ "Enable dead code elimination" },
{"leading-underscore", &flag_leading_underscore, 1,
"External symbols have a leading underscore" },
{"ident", &flag_no_ident, 0,
@@ -2976,13 +2984,25 @@ rest_of_compilation (decl)
close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
timevar_pop (TV_TO_SSA);
- /* Currently, there's nothing to do in SSA form. */
-
/* The SSA implementation uses basic block numbers in its phi
nodes. Thus, changing the control-flow graph or the basic
blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
may cause problems. */
+ if (flag_dce)
+ {
+ /* Remove dead code. */
+
+ timevar_push (TV_DEAD_CODE_ELIM);
+ open_dump_file (DFI_dce, decl);
+
+ insns = get_insns ();
+ eliminate_dead_code();
+
+ close_dump_file (DFI_dce, print_rtl_with_bb, insns);
+ timevar_pop (TV_DEAD_CODE_ELIM);
+ }
+
/* Convert from SSA form. */
timevar_push (TV_FROM_SSA);