diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 43ae71725794..93a357a7481e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,58 @@ +2013-10-18 Andrew MacLeod + + * tree-ssa.h: Don't include gimple-low.h, tree-ssa-address.h, sbitmap.h, + tree-ssa-threadedge.h, tree-ssa-dom.h, and tree-cfgcleanup.h. + * gimple-low.c (gimple_check_call_arg, + gimple_check_call_matching_types): Move to cgraph.c. + * gimple-low.h: Remove prototype. + * cgraph.c: (gimple_check_call_arg, gimple_check_call_matching_types): + Relocate from gimple-low.c. + * cgraph.h: Add prototype. Don't include basic-block.h. + * gimplify.c: Add gimple-low to include list. + * omp-low.c: Add gimple-low and tree-cfgcleanup.h to include list. + * tree-eh.c: Add gimple-low to include list. + * tree-nested.c: Likewise. + * cfgexpand.c: Add tree-ssa-address.h to include list. + * expr.c: Likewise. + * gimple-fold.c: Likewise. + * gimple-ssa-strength-reduction.c: Likewise. + * trans-mem.c: Likewise. + * tree-mudflap.c: Likewise. + * tree-ssa-loop-ivopts.c: Likewise. + * tree-ssa-dom.c: Include tree-ssa-threadedge.h and tree-ssa-dom.h. + (degenerate_phi_result): Move to tree-phinodes.c. + * tree-ssa-loop-ch.c: Include tree-ssa-threadedge.h. + * tree-ssa-threadedge.c: Likewise. + * tree-vrp.c: Likewise. + * tree-phinodes.c (degenerate_phi_result): Relocate here. + * tree-ssa-dom.h (degenerate_phi_result): Remove Prototype. + * tree-phinodes.h (degenerate_phi_result): Add prototype. + * tree-ssa-copy.c: Include tree-ssa-dom.h. + * tree-ssa-forwprop.c: Likewise. + * tree-cfgcleanup.c (execute_cleanup_cfg_post_optimizing, + pass_data_cleanup_cfg_post_optimizing, + make_pass_cleanup_cfg_post_optimizing): Relocate from tree-optimize.c. + * tree-optimize.c: Delete File. + * graphite.c: Include tree-cfgcleanup.h. + * passes.c: Likewise. + * tree-cfg.c: Likewise. + * tree-profile.c: Likewise. + * tree-ssa-dse.c: Likewise. + * tree-ssa-loop-ivcanon.c: Likewise. + * tree-switch-conversion.c: Don't include tree-ssa-operands.h. + * tree-outof-ssa.c: Include sbitmap.h. + * tree-ssa-live.c: Likewise. + * tree-ssa-propagate.c: Likewise. + * tree-ssa-structalias.c: Likewise. + * tree-stdarg.c: Likewise. + * Makefile.in (OBJS): Delete tree-optimize.o. + * basic-block.h (gcov_type, gcov_type_unsigned): Move to coretypes.h. + * coretypes.h (gcov_type, gcov_type_unsigned): Relocate here. + * varasm.c: Include basic-block.h. + * cfgloop.h: Include function.h instead of basic-block.h + (bb_loop_depth): Move to cfgloop.c. + * cfgloop.c (bb_loop_depth): Relocate from cfgloop.h. + 2013-10-18 Teresa Johnson * predict.c (probably_never_executed): Compare frequency-based diff --git a/gcc/Makefile.in b/gcc/Makefile.in index ba39ac934ad3..f0b8c5a23f27 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1391,7 +1391,6 @@ OBJS = \ tree-nomudflap.o \ tree-nrv.o \ tree-object-size.o \ - tree-optimize.o \ tree-outof-ssa.o \ tree-parloops.o \ tree-phinodes.o \ diff --git a/gcc/basic-block.h b/gcc/basic-block.h index f51de82f6c20..f0820b297d03 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -24,13 +24,11 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "function.h" -/* Type we use to hold basic block counters. Should be at least +/* Use gcov_type to hold basic block counters. Should be at least 64bit. Although a counter cannot be negative, we use a signed type, because erroneous negative counts can be generated when the flow graph is manipulated by various optimizations. A signed type makes those easy to detect. */ -typedef HOST_WIDEST_INT gcov_type; -typedef unsigned HOST_WIDEST_INT gcov_type_unsigned; /* Control flow edge information. */ struct GTY((user)) edge_def { diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 7ed29f5c2273..5a78bb68b35a 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see #include "regs.h" /* For reg_renumber. */ #include "insn-attr.h" /* For INSN_SCHEDULING. */ #include "asan.h" +#include "tree-ssa-address.h" /* This variable holds information helping the rewriting of SSA trees into RTL. */ diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 28e30eaa905e..3babf777fae7 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -1912,4 +1912,10 @@ get_max_loop_iterations_int (struct loop *loop) return hwi_nit < 0 ? -1 : hwi_nit; } +/* Returns the loop depth of the loop BB belongs to. */ +int +bb_loop_depth (const_basic_block bb) +{ + return bb->loop_father ? loop_depth (bb->loop_father) : 0; +} diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index b9676ec02514..87086d49022b 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -20,11 +20,10 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_CFGLOOP_H #define GCC_CFGLOOP_H -#include "basic-block.h" #include "double-int.h" - #include "bitmap.h" #include "sbitmap.h" +#include "function.h" /* Structure to hold decision about unrolling/peeling. */ enum lpt_dec @@ -455,14 +454,6 @@ loop_depth (const struct loop *loop) return vec_safe_length (loop->superloops); } -/* Returns the loop depth of the loop BB belongs to. */ - -static inline int -bb_loop_depth (const_basic_block bb) -{ - return bb->loop_father ? loop_depth (bb->loop_father) : 0; -} - /* Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost loop. */ @@ -744,6 +735,7 @@ extern HOST_WIDE_INT get_estimated_loop_iterations_int (struct loop *); extern HOST_WIDE_INT get_max_loop_iterations_int (struct loop *); extern bool get_estimated_loop_iterations (struct loop *loop, double_int *nit); extern bool get_max_loop_iterations (struct loop *loop, double_int *nit); +extern int bb_loop_depth (const_basic_block); /* Converts VAL to double_int. */ diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 124ee0adf855..6ebd0c71e026 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -2998,4 +2998,99 @@ cgraph_get_body (struct cgraph_node *node) return true; } +/* Verify if the type of the argument matches that of the function + declaration. If we cannot verify this or there is a mismatch, + return false. */ + +static bool +gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) +{ + tree parms, p; + unsigned int i, nargs; + + /* Calls to internal functions always match their signature. */ + if (gimple_call_internal_p (stmt)) + return true; + + nargs = gimple_call_num_args (stmt); + + /* Get argument types for verification. */ + if (fndecl) + parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); + else + parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt)); + + /* Verify if the type of the argument matches that of the function + declaration. If we cannot verify this or there is a mismatch, + return false. */ + if (fndecl && DECL_ARGUMENTS (fndecl)) + { + for (i = 0, p = DECL_ARGUMENTS (fndecl); + i < nargs; + i++, p = DECL_CHAIN (p)) + { + tree arg; + /* We cannot distinguish a varargs function from the case + of excess parameters, still deferring the inlining decision + to the callee is possible. */ + if (!p) + break; + arg = gimple_call_arg (stmt, i); + if (p == error_mark_node + || arg == error_mark_node + || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) + && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) + return false; + } + if (args_count_match && p) + return false; + } + else if (parms) + { + for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) + { + tree arg; + /* If this is a varargs function defer inlining decision + to callee. */ + if (!p) + break; + arg = gimple_call_arg (stmt, i); + if (TREE_VALUE (p) == error_mark_node + || arg == error_mark_node + || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE + || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) + && !fold_convertible_p (TREE_VALUE (p), arg))) + return false; + } + } + else + { + if (nargs != 0) + return false; + } + return true; +} + +/* Verify if the type of the argument and lhs of CALL_STMT matches + that of the function declaration CALLEE. If ARGS_COUNT_MATCH is + true, the arg count needs to be the same. + If we cannot verify this or there is a mismatch, return false. */ + +bool +gimple_check_call_matching_types (gimple call_stmt, tree callee, + bool args_count_match) +{ + tree lhs; + + if ((DECL_RESULT (callee) + && !DECL_BY_REFERENCE (DECL_RESULT (callee)) + && (lhs = gimple_call_lhs (call_stmt)) != NULL_TREE + && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), + TREE_TYPE (lhs)) + && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) + || !gimple_check_call_args (call_stmt, callee, args_count_match)) + return false; + return true; +} + #include "gt-cgraph.h" diff --git a/gcc/cgraph.h b/gcc/cgraph.h index afdeaba4c3d9..69adf4d19161 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -25,7 +25,6 @@ along with GCC; see the file COPYING3. If not see #include "plugin-api.h" #include "vec.h" #include "tree.h" -#include "basic-block.h" #include "function.h" #include "ipa-ref.h" @@ -742,6 +741,7 @@ void cgraph_speculative_call_info (struct cgraph_edge *, struct cgraph_edge *&, struct cgraph_edge *&, struct ipa_ref *&); +extern bool gimple_check_call_matching_types (gimple, tree, bool); /* In cgraphunit.c */ struct asm_node *add_asm_node (tree); diff --git a/gcc/coretypes.h b/gcc/coretypes.h index bff8f5c62d5d..f7ef8d777c1f 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -43,6 +43,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef USED_FOR_TARGET +typedef HOST_WIDEST_INT gcov_type; +typedef unsigned HOST_WIDEST_INT gcov_type_unsigned; + struct bitmap_head_def; typedef struct bitmap_head_def *bitmap; typedef const struct bitmap_head_def *const_bitmap; diff --git a/gcc/expr.c b/gcc/expr.c index 4975a64e1d86..76ee9e0ab7f0 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-outof-ssa.h" #include "target-globals.h" #include "params.h" +#include "tree-ssa-address.h" /* Decide whether a function's arguments should be processed from first to last or from last to first. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 33e677f246eb..d1349588fbdf 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "ipa-utils.h" #include "gimple-pretty-print.h" +#include "tree-ssa-address.h" /* Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index aa4c024b1ced..cf61204c411a 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-core.h" #include "tree-pass.h" #include "langhooks.h" +#include "gimple-low.h" /* The differences between High GIMPLE and Low GIMPLE are the following: @@ -215,103 +216,6 @@ make_pass_lower_cf (gcc::context *ctxt) return new pass_lower_cf (ctxt); } - - -/* Verify if the type of the argument matches that of the function - declaration. If we cannot verify this or there is a mismatch, - return false. */ - -static bool -gimple_check_call_args (gimple stmt, tree fndecl, bool args_count_match) -{ - tree parms, p; - unsigned int i, nargs; - - /* Calls to internal functions always match their signature. */ - if (gimple_call_internal_p (stmt)) - return true; - - nargs = gimple_call_num_args (stmt); - - /* Get argument types for verification. */ - if (fndecl) - parms = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); - else - parms = TYPE_ARG_TYPES (gimple_call_fntype (stmt)); - - /* Verify if the type of the argument matches that of the function - declaration. If we cannot verify this or there is a mismatch, - return false. */ - if (fndecl && DECL_ARGUMENTS (fndecl)) - { - for (i = 0, p = DECL_ARGUMENTS (fndecl); - i < nargs; - i++, p = DECL_CHAIN (p)) - { - tree arg; - /* We cannot distinguish a varargs function from the case - of excess parameters, still deferring the inlining decision - to the callee is possible. */ - if (!p) - break; - arg = gimple_call_arg (stmt, i); - if (p == error_mark_node - || arg == error_mark_node - || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg)) - && !fold_convertible_p (DECL_ARG_TYPE (p), arg))) - return false; - } - if (args_count_match && p) - return false; - } - else if (parms) - { - for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p)) - { - tree arg; - /* If this is a varargs function defer inlining decision - to callee. */ - if (!p) - break; - arg = gimple_call_arg (stmt, i); - if (TREE_VALUE (p) == error_mark_node - || arg == error_mark_node - || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE - || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg)) - && !fold_convertible_p (TREE_VALUE (p), arg))) - return false; - } - } - else - { - if (nargs != 0) - return false; - } - return true; -} - -/* Verify if the type of the argument and lhs of CALL_STMT matches - that of the function declaration CALLEE. If ARGS_COUNT_MATCH is - true, the arg count needs to be the same. - If we cannot verify this or there is a mismatch, return false. */ - -bool -gimple_check_call_matching_types (gimple call_stmt, tree callee, - bool args_count_match) -{ - tree lhs; - - if ((DECL_RESULT (callee) - && !DECL_BY_REFERENCE (DECL_RESULT (callee)) - && (lhs = gimple_call_lhs (call_stmt)) != NULL_TREE - && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)), - TREE_TYPE (lhs)) - && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs)) - || !gimple_check_call_args (call_stmt, callee, args_count_match)) - return false; - return true; -} - /* Lower sequence SEQ. Unlike gimplification the statements are not relowered when they are changed -- if this has to be done, the lowering routine must do it explicitly. DATA is passed through the recursion. */ diff --git a/gcc/gimple-low.h b/gcc/gimple-low.h index b66de2ef2c2c..7e8ff6c74d8b 100644 --- a/gcc/gimple-low.h +++ b/gcc/gimple-low.h @@ -20,7 +20,6 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_GIMPLE_LOW_H #define GCC_GIMPLE_LOW_H -extern bool gimple_check_call_matching_types (gimple, tree, bool); extern bool gimple_stmt_may_fallthru (gimple); extern bool gimple_seq_may_fallthru (gimple_seq); extern void record_vars_into (tree, tree); diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index a558f349c410..2b5e69f77251 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "expmed.h" #include "params.h" #include "hash-table.h" +#include "tree-ssa-address.h" /* Information about a strength reduction candidate. Each statement in the candidate table represents an expression of one of the diff --git a/gcc/gimplify.c b/gcc/gimplify.c index a67f1a3746ec..193e0170178e 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "splay-tree.h" #include "vec.h" #include "omp-low.h" +#include "gimple-low.h" #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */ #include "tree-pass.h" /* FIXME: only for PROP_gimple_any */ diff --git a/gcc/graphite.c b/gcc/graphite.c index 7273c1120844..b26c520abcbf 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "dbgcnt.h" #include "tree-parloops.h" #include "tree-pass.h" +#include "tree-cfgcleanup.h" #ifdef HAVE_cloog diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 208f20c407de..3326e9ecf0cf 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -44,6 +44,8 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "target.h" #include "omp-low.h" +#include "gimple-low.h" +#include "tree-cfgcleanup.h" /* Lowering of OpenMP parallel and workshare constructs proceeds in two diff --git a/gcc/passes.c b/gcc/passes.c index 5e6b8e5cc016..95fc66694408 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -73,6 +73,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "pass_manager.h" #include "tree-ssa-live.h" /* For remove_unused_locals. */ +#include "tree-cfgcleanup.h" using namespace gcc; diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 82f3ee08a39b..037cbcef7436 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -35,6 +35,7 @@ #include "langhooks.h" #include "gimple-pretty-print.h" #include "cfgloop.h" +#include "tree-ssa-address.h" #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 9268615395ab..3a1319132d56 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "tree-ssa-live.h" #include "omp-low.h" +#include "tree-cfgcleanup.h" /* This file contains functions for building the Control Flow Graph (CFG) for a function tree. */ diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index cd4307ec9b8b..830cdf36b6b9 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -1027,3 +1027,90 @@ make_pass_merge_phi (gcc::context *ctxt) { return new pass_merge_phi (ctxt); } + +/* Pass: cleanup the CFG just before expanding trees to RTL. + This is just a round of label cleanups and case node grouping + because after the tree optimizers have run such cleanups may + be necessary. */ + +static unsigned int +execute_cleanup_cfg_post_optimizing (void) +{ + unsigned int todo = 0; + if (cleanup_tree_cfg ()) + todo |= TODO_update_ssa; + maybe_remove_unreachable_handlers (); + cleanup_dead_labels (); + group_case_labels (); + if ((flag_compare_debug_opt || flag_compare_debug) + && flag_dump_final_insns) + { + FILE *final_output = fopen (flag_dump_final_insns, "a"); + + if (!final_output) + { + error ("could not open final insn dump file %qs: %m", + flag_dump_final_insns); + flag_dump_final_insns = NULL; + } + else + { + int save_unnumbered = flag_dump_unnumbered; + int save_noaddr = flag_dump_noaddr; + + flag_dump_noaddr = flag_dump_unnumbered = 1; + fprintf (final_output, "\n"); + dump_enumerated_decls (final_output, dump_flags | TDF_NOUID); + flag_dump_noaddr = save_noaddr; + flag_dump_unnumbered = save_unnumbered; + if (fclose (final_output)) + { + error ("could not close final insn dump file %qs: %m", + flag_dump_final_insns); + flag_dump_final_insns = NULL; + } + } + } + return todo; +} + +namespace { + +const pass_data pass_data_cleanup_cfg_post_optimizing = +{ + GIMPLE_PASS, /* type */ + "optimized", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + false, /* has_gate */ + true, /* has_execute */ + TV_TREE_CLEANUP_CFG, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_remove_unused_locals, /* todo_flags_finish */ +}; + +class pass_cleanup_cfg_post_optimizing : public gimple_opt_pass +{ +public: + pass_cleanup_cfg_post_optimizing (gcc::context *ctxt) + : gimple_opt_pass (pass_data_cleanup_cfg_post_optimizing, ctxt) + {} + + /* opt_pass methods: */ + unsigned int execute () { + return execute_cleanup_cfg_post_optimizing (); + } + +}; // class pass_cleanup_cfg_post_optimizing + +} // anon namespace + +gimple_opt_pass * +make_pass_cleanup_cfg_post_optimizing (gcc::context *ctxt) +{ + return new pass_cleanup_cfg_post_optimizing (ctxt); +} + + diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 9eaae1170ab1..9c7817d42e25 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "target.h" #include "cfgloop.h" +#include "gimple-low.h" /* In some instances a tree and a gimple need to be stored in a same table, i.e. in hash tables. This is a structure to do this. */ diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c index 9616762f24ed..4c0d71d757bd 100644 --- a/gcc/tree-mudflap.c +++ b/gcc/tree-mudflap.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "ggc.h" #include "cgraph.h" #include "gimple.h" +#include "tree-ssa-address.h" extern void add_bb_to_loop (basic_block, struct loop *); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 7582289c1c2c..b0922f6aabdd 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -33,6 +33,7 @@ #include "expr.h" /* FIXME: For STACK_SAVEAREA_MODE and SAVE_NONLOCAL. */ #include "langhooks.h" #include "pointer-set.h" +#include "gimple-low.h" /* The object of this pass is to lower the representation of a set of nested diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c deleted file mode 100644 index d823dbed412d..000000000000 --- a/gcc/tree-optimize.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Top-level control of tree optimizations. - Copyright (C) 2001-2013 Free Software Foundation, Inc. - Contributed by Diego Novillo - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "tm.h" -#include "tree.h" -#include "tm_p.h" -#include "basic-block.h" -#include "flags.h" -#include "tree-ssa.h" -#include "function.h" -#include "langhooks.h" -#include "diagnostic-core.h" -#include "toplev.h" -#include "flags.h" -#include "cgraph.h" -#include "tree-inline.h" -#include "tree-pass.h" -#include "ggc.h" -#include "cgraph.h" -#include "cfgloop.h" -#include "except.h" -#include "plugin.h" - - -/* Pass: cleanup the CFG just before expanding trees to RTL. - This is just a round of label cleanups and case node grouping - because after the tree optimizers have run such cleanups may - be necessary. */ - -static unsigned int -execute_cleanup_cfg_post_optimizing (void) -{ - unsigned int todo = 0; - if (cleanup_tree_cfg ()) - todo |= TODO_update_ssa; - maybe_remove_unreachable_handlers (); - cleanup_dead_labels (); - group_case_labels (); - if ((flag_compare_debug_opt || flag_compare_debug) - && flag_dump_final_insns) - { - FILE *final_output = fopen (flag_dump_final_insns, "a"); - - if (!final_output) - { - error ("could not open final insn dump file %qs: %m", - flag_dump_final_insns); - flag_dump_final_insns = NULL; - } - else - { - int save_unnumbered = flag_dump_unnumbered; - int save_noaddr = flag_dump_noaddr; - - flag_dump_noaddr = flag_dump_unnumbered = 1; - fprintf (final_output, "\n"); - dump_enumerated_decls (final_output, dump_flags | TDF_NOUID); - flag_dump_noaddr = save_noaddr; - flag_dump_unnumbered = save_unnumbered; - if (fclose (final_output)) - { - error ("could not close final insn dump file %qs: %m", - flag_dump_final_insns); - flag_dump_final_insns = NULL; - } - } - } - return todo; -} - -namespace { - -const pass_data pass_data_cleanup_cfg_post_optimizing = -{ - GIMPLE_PASS, /* type */ - "optimized", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - false, /* has_gate */ - true, /* has_execute */ - TV_TREE_CLEANUP_CFG, /* tv_id */ - PROP_cfg, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - TODO_remove_unused_locals, /* todo_flags_finish */ -}; - -class pass_cleanup_cfg_post_optimizing : public gimple_opt_pass -{ -public: - pass_cleanup_cfg_post_optimizing (gcc::context *ctxt) - : gimple_opt_pass (pass_data_cleanup_cfg_post_optimizing, ctxt) - {} - - /* opt_pass methods: */ - unsigned int execute () { - return execute_cleanup_cfg_post_optimizing (); - } - -}; // class pass_cleanup_cfg_post_optimizing - -} // anon namespace - -gimple_opt_pass * -make_pass_cleanup_cfg_post_optimizing (gcc::context *ctxt) -{ - return new pass_cleanup_cfg_post_optimizing (ctxt); -} - - diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 42c90d49a180..f732e09d6fe7 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "gimple-pretty-print.h" #include "bitmap.h" +#include "sbitmap.h" #include "tree-ssa.h" #include "dumpfile.h" #include "diagnostic-core.h" diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 0bd5085ba993..f96dafa476c9 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -464,4 +464,41 @@ remove_phi_nodes (basic_block bb) set_phi_nodes (bb, NULL); } +/* Given PHI, return its RHS if the PHI is a degenerate, otherwise return + NULL. */ + +tree +degenerate_phi_result (gimple phi) +{ + tree lhs = gimple_phi_result (phi); + tree val = NULL; + size_t i; + + /* Ignoring arguments which are the same as LHS, if all the remaining + arguments are the same, then the PHI is a degenerate and has the + value of that common argument. */ + for (i = 0; i < gimple_phi_num_args (phi); i++) + { + tree arg = gimple_phi_arg_def (phi, i); + + if (arg == lhs) + continue; + else if (!arg) + break; + else if (!val) + val = arg; + else if (arg == val) + continue; + /* We bring in some of operand_equal_p not only to speed things + up, but also to avoid crashing when dereferencing the type of + a released SSA name. */ + else if (TREE_CODE (val) != TREE_CODE (arg) + || TREE_CODE (val) == SSA_NAME + || !operand_equal_p (arg, val, 0)) + break; + } + return (i == gimple_phi_num_args (phi) ? val : NULL); +} + + #include "gt-tree-phinodes.h" diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h index e36106922118..ae6222b336ed 100644 --- a/gcc/tree-phinodes.h +++ b/gcc/tree-phinodes.h @@ -29,7 +29,7 @@ extern void add_phi_arg (gimple, tree, edge, source_location); extern void remove_phi_args (edge); extern void remove_phi_node (gimple_stmt_iterator *, bool); extern void remove_phi_nodes (basic_block); -/* Return a use_operand_p pointer for argument I of PHI node GS. */ +extern tree degenerate_phi_result (gimple); /* Set PHI nodes of a basic block BB to SEQ. */ diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index a0e49b530475..d5713ac65213 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "profile.h" #include "target.h" +#include "tree-cfgcleanup.h" static GTY(()) tree gcov_type_node; static GTY(()) tree tree_interval_profiler_fn; diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index c85749d511dc..4ec941bcbf0b 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "cfgloop.h" #include "tree-scalar-evolution.h" +#include "tree-ssa-dom.h" /* This file implements the copy propagation pass and provides a handful of interfaces for performing const/copy propagation and diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index b2c7e147ef67..4ce29aed54e3 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-threadupdate.h" #include "langhooks.h" #include "params.h" +#include "tree-ssa-threadedge.h" +#include "tree-ssa-dom.h" /* This file implements optimizations on the dominator tree. */ @@ -2588,42 +2590,6 @@ avail_expr_hash (const void *p) /* PHI-ONLY copy and constant propagation. This pass is meant to clean up degenerate PHIs created by or exposed by jump threading. */ -/* Given PHI, return its RHS if the PHI is a degenerate, otherwise return - NULL. */ - -tree -degenerate_phi_result (gimple phi) -{ - tree lhs = gimple_phi_result (phi); - tree val = NULL; - size_t i; - - /* Ignoring arguments which are the same as LHS, if all the remaining - arguments are the same, then the PHI is a degenerate and has the - value of that common argument. */ - for (i = 0; i < gimple_phi_num_args (phi); i++) - { - tree arg = gimple_phi_arg_def (phi, i); - - if (arg == lhs) - continue; - else if (!arg) - break; - else if (!val) - val = arg; - else if (arg == val) - continue; - /* We bring in some of operand_equal_p not only to speed things - up, but also to avoid crashing when dereferencing the type of - a released SSA name. */ - else if (TREE_CODE (val) != TREE_CODE (arg) - || TREE_CODE (val) == SSA_NAME - || !operand_equal_p (arg, val, 0)) - break; - } - return (i == gimple_phi_num_args (phi) ? val : NULL); -} - /* Given a statement STMT, which is either a PHI node or an assignment, remove it from the IL. */ diff --git a/gcc/tree-ssa-dom.h b/gcc/tree-ssa-dom.h index 89742b03a0e3..0115f9323b7d 100644 --- a/gcc/tree-ssa-dom.h +++ b/gcc/tree-ssa-dom.h @@ -24,6 +24,5 @@ extern void dump_dominator_optimization_stats (FILE *); extern void debug_dominator_optimization_stats (void); extern int loop_depth_of_name (tree); extern bool simple_iv_increment_p (gimple); -extern tree degenerate_phi_result (gimple); #endif /* GCC_TREE_SSA_DOM_H */ diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 700824cade89..f73fb3c522b9 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "domwalk.h" #include "flags.h" #include "langhooks.h" +#include "tree-cfgcleanup.h" /* This file implements dead store elimination. diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 65f7ee17d46b..456725d3e3b0 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "optabs.h" #include "tree-ssa-propagate.h" +#include "tree-ssa-dom.h" /* This pass propagates the RHS of assignment statements into use sites of the LHS of the assignment. It's basically a specialized diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 7705f1312b86..94a9beead585 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "gimple-pretty-print.h" #include "bitmap.h" +#include "sbitmap.h" #include "tree-ssa.h" #include "timevar.h" #include "dumpfile.h" diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index b74855e62de8..15b34bb9d0c1 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "tree-inline.h" #include "flags.h" +#include "tree-ssa-threadedge.h" /* Duplicates headers of loops if they are small enough, so that the statements in the loop body are always executed when the loop is entered. This diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 8db5b9ede7e7..a506706b6e8f 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "tree-inline.h" #include "target.h" +#include "tree-cfgcleanup.h" /* Specifies types of loops that may be unrolled. */ diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 5e8fa36f3949..798f57f6c284 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -86,6 +86,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-ssa-propagate.h" #include "expmed.h" +#include "tree-ssa-address.h" /* FIXME: Expressions are expanded to RTL in this pass to determine the cost of different addressing modes. This should be moved to a TBD diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 591f5508f665..180ae85e091a 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -29,6 +29,7 @@ #include "function.h" #include "gimple-pretty-print.h" #include "dumpfile.h" +#include "sbitmap.h" #include "tree-ssa.h" #include "tree-ssa-propagate.h" #include "langhooks.h" diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 46acc9ab9add..b8cfebd31105 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -25,6 +25,7 @@ #include "ggc.h" #include "obstack.h" #include "bitmap.h" +#include "sbitmap.h" #include "flags.h" #include "basic-block.h" #include "tree.h" diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index c2dd0155697e..f5675572ff03 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-threadupdate.h" #include "langhooks.h" #include "params.h" +#include "tree-ssa-threadedge.h" /* To avoid code explosion due to jump threading, we limit the number of statements we are going to copy. This variable diff --git a/gcc/tree-ssa.h b/gcc/tree-ssa.h index 8c26fd1a2fe6..c68a044221c4 100644 --- a/gcc/tree-ssa.h +++ b/gcc/tree-ssa.h @@ -21,21 +21,15 @@ along with GCC; see the file COPYING3. If not see #define GCC_TREE_SSA_H #include "bitmap.h" -#include "sbitmap.h" #include "gimple.h" #include "gimple-ssa.h" #include "cgraph.h" -#include "tree-cfgcleanup.h" #include "tree-cfg.h" #include "tree-phinodes.h" #include "ssa-iterators.h" #include "tree-ssanames.h" -#include "tree-ssa-dom.h" -#include "tree-ssa-threadedge.h" -#include "tree-ssa-address.h" #include "tree-ssa-loop.h" #include "tree-into-ssa.h" -#include "gimple-low.h" #include "tree-dfa.h" /* Mapping for redirected edges. */ diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index d7cd291f3a84..3314fbaf56ea 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-pretty-print.h" #include "target.h" #include "tree-ssa.h" +#include "sbitmap.h" #include "tree-pass.h" #include "tree-stdarg.h" diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 04beab6bf754..862cb3870c8c 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -32,7 +32,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tree.h" #include "basic-block.h" #include "tree-ssa.h" -#include "tree-ssa-operands.h" #include "tree-pass.h" #include "gimple-pretty-print.h" #include "cfgloop.h" diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 2bc15812e5a0..0a059645c50c 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-threadupdate.h" #include "expr.h" #include "optabs.h" +#include "tree-ssa-threadedge.h" diff --git a/gcc/varasm.c b/gcc/varasm.c index 12fb7c46b33c..acf8af083d4d 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "pointer-set.h" #include "asan.h" +#include "basic-block.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" /* Needed for external data