From 381cdae49785fc4b1941a6b37bad3e8c6f3f428d Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 3 May 2016 12:06:19 +0000 Subject: [PATCH] gimplify.h (get_initialized_tmp_var): Add allow_ssa parameter default true. 2016-05-03 Richard Biener * gimplify.h (get_initialized_tmp_var): Add allow_ssa parameter default true. (gimplify_arg): Likewise. * gimplify.c (gimplify_expr): Add overload with allow_ssa parameter, re-writing the result to a decl if required. (internal_get_tmp_var): Add allow_ssa parameter and override into_ssa with it. (get_formal_tmp_var): Adjust. (get_initialized_tmp_var): Add allow_ssa parameter. (gimplify_arg): Add allow_ssa parameter and avoid generating SSA names for the result false. (gimplify_call_expr): If the call may return twice do not gimplify parameters into SSA. (prepare_gimple_addressable): Do not allow an SSA name as temporary. (gimplify_modify_expr): Adjust assert. For noreturn calls with a SSA name LHS adjust its def. (gimplify_save_expr): Do not allow an SSA name as save-expr result. (gimplify_one_sizepos): Do not allow an SSA name as a sizepos. (gimplify_body): Init GIMPLE SSA data structures and gimplify into-SSA. (gimplify_scan_omp_clauses): Make sure OMP_CLAUSE_SIZE is not an SSA name. Likewise for OMP_CLAUSE_REDUCTION operands. (gimplify_omp_for): Likewise for OMP_CLAUSE_DECL. Likewise for OMP_FOR_COND, OMP_FOR_INCR and OMP_CLAUSE_LINEAR_STEP. (optimize_target_teams): Do not allow SSA names for clause operands. (gimplify_expr): Likewise for where we mark the result addressable. * passes.def (pass_init_datastructures): Remove. * tree-into-ssa.c (mark_def_sites): Ignore existing SSA names. (rewrite_stmt): Likewise. * tree-inline.c (initialize_cfun): Properly transfer SSA state. (replace_locals_op): Replace SSA names. (copy_gimple_seq_and_replace_locals): Init src_cfun. * gimple-low.c (lower_builtin_setjmp): Deal with SSA. * cgraph.c (release_function_body): Free CFG annotations only when we have a CFG. Simplify. * gimple-fold.c (gimplify_and_update_call_from_tree): Use force_gimple_operand instead of get_initialized_tmp_var. * tree-pass.h (make_pass_init_datastructures): Remove. * tree-ssa.c (execute_init_datastructures): Remove. (pass_data_init_datastructures): Likewise. (class pass_init_datastructures): Likewise. (make_pass_init_datastructures): Likewise. * omp-low.c (create_omp_child_function): Init SSA data structures. (grid_expand_target_grid_body): Likewise. * tree-cfg.c (move_block_to_fn): Double-check the DEF is an SSA name before adding it to names_to_release. (remove_bb): Always release SSA defs. * tree-ssa-ccp.c (get_default_value): Check SSA_NAME_VAR before dereferencing it. * cgraphunit.c (init_lowered_empty_function): Always int SSA data structures. * tree-ssanames.c (release_defs): Remove assert that we are in SSA form. * trans-mem.c (diagnose_tm_1): Handle SSA name function. c-family/ * cilk.c (cilk_gimplify_call_params_in_spawned_fn): Do not allow call args to gimplify to SSA names. * gcc.dg/pr30172-1.c: Adjust. * gcc.dg/pr63743.c: Likewise. * gcc.dg/tm/pr51696.c: Likewise. * c-c++-common/tm/safe-1.c: Likewise. * gcc.dg/tree-prof/val-prof-3.c: Likewise. * gcc.dg/plugin/self-assign-test-1.c: XFAIL case that needs CSE. * g++.dg/plugin/self-assign-test-1.C: Likewise. * g++.dg/plugin/self-assign-test-2.C: Likewise. From-SVN: r235817 --- gcc/ChangeLog | 59 +++++++++ gcc/c-family/ChangeLog | 5 + gcc/c-family/cilk.c | 10 +- gcc/cgraph.c | 40 +++--- gcc/cgraphunit.c | 2 +- gcc/gimple-fold.c | 2 +- gcc/gimple-low.c | 11 +- gcc/gimplify.c | 125 +++++++++++++----- gcc/gimplify.h | 6 +- gcc/omp-low.c | 2 + gcc/passes.def | 1 - gcc/testsuite/ChangeLog | 11 ++ gcc/testsuite/c-c++-common/tm/safe-1.c | 12 +- .../g++.dg/plugin/self-assign-test-1.C | 2 +- .../g++.dg/plugin/self-assign-test-2.C | 2 +- gcc/testsuite/gcc.dg/fold-perm.c | 8 +- .../gcc.dg/plugin/self-assign-test-1.c | 2 +- gcc/testsuite/gcc.dg/pr30172-1.c | 4 +- gcc/testsuite/gcc.dg/pr63743.c | 3 +- gcc/testsuite/gcc.dg/tm/pr51696.c | 2 +- gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-43.c | 5 +- gcc/trans-mem.c | 6 +- gcc/tree-cfg.c | 9 +- gcc/tree-inline.c | 23 +++- gcc/tree-into-ssa.c | 8 ++ gcc/tree-pass.h | 1 - gcc/tree-ssa-ccp.c | 1 + gcc/tree-ssa.c | 56 -------- gcc/tree-ssanames.c | 4 - 31 files changed, 268 insertions(+), 158 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b1b95b5fff..ba7f10d6d2a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,62 @@ +2016-05-03 Richard Biener + + * gimplify.h (get_initialized_tmp_var): Add allow_ssa parameter + default true. + (gimplify_arg): Likewise. + * gimplify.c (gimplify_expr): Add overload with allow_ssa parameter, + re-writing the result to a decl if required. + (internal_get_tmp_var): Add allow_ssa parameter + and override into_ssa with it. + (get_formal_tmp_var): Adjust. + (get_initialized_tmp_var): Add allow_ssa parameter. + (gimplify_arg): Add allow_ssa parameter and avoid generating + SSA names for the result false. + (gimplify_call_expr): If the call may return twice do not + gimplify parameters into SSA. + (prepare_gimple_addressable): Do not allow an SSA name as + temporary. + (gimplify_modify_expr): Adjust assert. For noreturn calls + with a SSA name LHS adjust its def. + (gimplify_save_expr): Do not allow an SSA name as save-expr + result. + (gimplify_one_sizepos): Do not allow an SSA name as a sizepos. + (gimplify_body): Init GIMPLE SSA data structures and gimplify + into-SSA. + (gimplify_scan_omp_clauses): Make sure OMP_CLAUSE_SIZE is not + an SSA name. Likewise for OMP_CLAUSE_REDUCTION operands. + (gimplify_omp_for): Likewise for OMP_CLAUSE_DECL. Likewise + for OMP_FOR_COND, OMP_FOR_INCR and OMP_CLAUSE_LINEAR_STEP. + (optimize_target_teams): Do not allow SSA names for clause operands. + (gimplify_expr): Likewise for where we mark the result addressable. + * passes.def (pass_init_datastructures): Remove. + * tree-into-ssa.c (mark_def_sites): Ignore existing SSA names. + (rewrite_stmt): Likewise. + * tree-inline.c (initialize_cfun): Properly transfer SSA state. + (replace_locals_op): Replace SSA names. + (copy_gimple_seq_and_replace_locals): Init src_cfun. + * gimple-low.c (lower_builtin_setjmp): Deal with SSA. + * cgraph.c (release_function_body): Free CFG annotations only + when we have a CFG. Simplify. + * gimple-fold.c (gimplify_and_update_call_from_tree): Use + force_gimple_operand instead of get_initialized_tmp_var. + * tree-pass.h (make_pass_init_datastructures): Remove. + * tree-ssa.c (execute_init_datastructures): Remove. + (pass_data_init_datastructures): Likewise. + (class pass_init_datastructures): Likewise. + (make_pass_init_datastructures): Likewise. + * omp-low.c (create_omp_child_function): Init SSA data structures. + (grid_expand_target_grid_body): Likewise. + * tree-cfg.c (move_block_to_fn): Double-check the DEF is an SSA + name before adding it to names_to_release. + (remove_bb): Always release SSA defs. + * tree-ssa-ccp.c (get_default_value): Check SSA_NAME_VAR + before dereferencing it. + * cgraphunit.c (init_lowered_empty_function): Always + int SSA data structures. + * tree-ssanames.c (release_defs): Remove assert that we are in + SSA form. + * trans-mem.c (diagnose_tm_1): Handle SSA name function. + 2016-05-03 Jakub Jelinek Uros Bizjak diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index fa750f765f8..b34e8ed82c9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2016-05-03 Richard Biener + + * cilk.c (cilk_gimplify_call_params_in_spawned_fn): Do not + allow call args to gimplify to SSA names. + 2016-05-03 Marek Polacek * c-common.h (enum c_omp_region_type): Remove stray comma. diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index 69a79baffea..8f34cd6c5e4 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -795,9 +795,13 @@ cilk_gimplify_call_params_in_spawned_fn (tree *expr_p, gimple_seq *pre_p) fix_parm_expr = &TREE_OPERAND (*expr_p, 1); if (TREE_CODE (*fix_parm_expr) == CALL_EXPR) - for (ii = 0; ii < call_expr_nargs (*fix_parm_expr); ii++) - gimplify_arg (&CALL_EXPR_ARG (*fix_parm_expr, ii), pre_p, - EXPR_LOCATION (*fix_parm_expr)); + { + /* Cilk outlining assumes GENERIC bodies, avoid leaking SSA names + via parameters. */ + for (ii = 0; ii < call_expr_nargs (*fix_parm_expr); ii++) + gimplify_arg (&CALL_EXPR_ARG (*fix_parm_expr, ii), pre_p, + EXPR_LOCATION (*fix_parm_expr), false); + } } diff --git a/gcc/cgraph.c b/gcc/cgraph.c index d93a93988f1..3105aec8255 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1729,30 +1729,26 @@ release_function_body (tree decl) if (fn) { if (fn->cfg - || fn->gimple_df) + && loops_for_fn (fn)) { - if (fn->cfg - && loops_for_fn (fn)) - { - fn->curr_properties &= ~PROP_loops; - loop_optimizer_finalize (fn); - } - if (fn->gimple_df) - { - delete_tree_ssa (fn); - delete_tree_cfg_annotations (fn); - fn->eh = NULL; - } - if (fn->cfg) - { - gcc_assert (!dom_info_available_p (fn, CDI_DOMINATORS)); - gcc_assert (!dom_info_available_p (fn, CDI_POST_DOMINATORS)); - clear_edges (fn); - fn->cfg = NULL; - } - if (fn->value_histograms) - free_histograms (fn); + fn->curr_properties &= ~PROP_loops; + loop_optimizer_finalize (fn); + } + if (fn->gimple_df) + { + delete_tree_ssa (fn); + fn->eh = NULL; + } + if (fn->cfg) + { + gcc_assert (!dom_info_available_p (fn, CDI_DOMINATORS)); + gcc_assert (!dom_info_available_p (fn, CDI_POST_DOMINATORS)); + delete_tree_cfg_annotations (fn); + clear_edges (fn); + fn->cfg = NULL; } + if (fn->value_histograms) + free_histograms (fn); gimple_set_body (decl, NULL); /* Struct function hangs a lot of data that would leak if we didn't removed all pointers to it. */ diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 4351ae49952..57618807c49 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1428,10 +1428,10 @@ init_lowered_empty_function (tree decl, bool in_ssa, gcov_type count) allocate_struct_function (decl, false); gimple_register_cfg_hooks (); init_empty_tree_cfg (); + init_tree_ssa (cfun); if (in_ssa) { - init_tree_ssa (cfun); init_ssa_operands (cfun); cfun->gimple_df->in_ssa_p = true; cfun->curr_properties |= PROP_ssa; diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index d5e859c9573..d3968e98620 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -542,7 +542,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) } else { - tree tmp = get_initialized_tmp_var (expr, &stmts, NULL); + tree tmp = force_gimple_operand (expr, &stmts, false, NULL_TREE); new_stmt = gimple_build_assign (lhs, tmp); i = gsi_last (stmts); gsi_insert_after_without_update (&i, new_stmt, diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index eb90d481a7d..9ea17af6637 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -740,7 +740,9 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) passed to both __builtin_setjmp_setup and __builtin_setjmp_receiver. */ FORCED_LABEL (next_label) = 1; - dest = gimple_call_lhs (stmt); + tree orig_dest = dest = gimple_call_lhs (stmt); + if (orig_dest && TREE_CODE (orig_dest) == SSA_NAME) + dest = create_tmp_reg (TREE_TYPE (orig_dest)); /* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert. */ arg = build_addr (next_label); @@ -789,6 +791,13 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) g = gimple_build_label (cont_label); gsi_insert_before (gsi, g, GSI_SAME_STMT); + /* Build orig_dest = dest if necessary. */ + if (dest != orig_dest) + { + g = gimple_build_assign (orig_dest, dest); + gsi_insert_before (gsi, g, GSI_SAME_STMT); + } + /* Remove the call to __builtin_setjmp. */ gsi_remove (gsi, false); } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index e223e592af5..9fe9bd5ed89 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -185,6 +185,8 @@ static struct gimplify_omp_ctx *gimplify_omp_ctxp; /* Forward declaration. */ static enum gimplify_status gimplify_compound_expr (tree *, gimple_seq *, bool); static hash_map *oacc_declare_returns; +static enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *, + bool (*) (tree), fallback_t, bool); /* Shorter alias name for the above function for use in gimplify.c only. */ @@ -547,7 +549,7 @@ lookup_tmp_var (tree val, bool is_formal) static tree internal_get_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p, - bool is_formal) + bool is_formal, bool allow_ssa) { tree t, mod; @@ -556,9 +558,18 @@ internal_get_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p, gimplify_expr (&val, pre_p, post_p, is_gimple_reg_rhs_or_call, fb_rvalue); - if (gimplify_ctxp->into_ssa + if (allow_ssa + && gimplify_ctxp->into_ssa && is_gimple_reg_type (TREE_TYPE (val))) - t = make_ssa_name (TYPE_MAIN_VARIANT (TREE_TYPE (val))); + { + t = make_ssa_name (TYPE_MAIN_VARIANT (TREE_TYPE (val))); + if (! gimple_in_ssa_p (cfun)) + { + const char *name = get_name (val); + if (name) + SET_SSA_NAME_VAR_OR_IDENTIFIER (t, create_tmp_var_name (name)); + } + } else t = lookup_tmp_var (val, is_formal); @@ -588,16 +599,17 @@ internal_get_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p, tree get_formal_tmp_var (tree val, gimple_seq *pre_p) { - return internal_get_tmp_var (val, pre_p, NULL, true); + return internal_get_tmp_var (val, pre_p, NULL, true, true); } /* Return a temporary variable initialized with VAL. PRE_P and POST_P are as in gimplify_expr. */ tree -get_initialized_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p) +get_initialized_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p, + bool allow_ssa) { - return internal_get_tmp_var (val, pre_p, post_p, false); + return internal_get_tmp_var (val, pre_p, post_p, false, allow_ssa); } /* Declare all the variables in VARS in SCOPE. If DEBUG_INFO is true, @@ -2279,10 +2291,12 @@ maybe_with_size_expr (tree *expr_p) /* Helper for gimplify_call_expr. Gimplify a single argument *ARG_P Store any side-effects in PRE_P. CALL_LOCATION is the location of - the CALL_EXPR. */ + the CALL_EXPR. If ALLOW_SSA is set the actual parameter may be + gimplified to an SSA name. */ enum gimplify_status -gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) +gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location, + bool allow_ssa) { bool (*test) (tree); fallback_t fb; @@ -2319,7 +2333,7 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) the argument list must occur before the actual call. So, when gimplifying arguments, force gimplify_expr to use an internal post queue which is then appended to the end of PRE_P. */ - return gimplify_expr (arg_p, pre_p, NULL, test, fb); + return gimplify_expr (arg_p, pre_p, NULL, test, fb, allow_ssa); } /* Don't fold inside offloading or taskreg regions: it can break code by @@ -2522,6 +2536,12 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) } } + /* If the call returns twice then after building the CFG the call + argument computations will no longer dominate the call because + we add an abnormal incoming edge to the call. So do not use SSA + vars there. */ + bool returns_twice = call_expr_flags (*expr_p) & ECF_RETURNS_TWICE; + /* Gimplify the function arguments. */ if (nargs > 0) { @@ -2536,7 +2556,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) if ((i != 1) || !builtin_va_start_p) { t = gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p, - EXPR_LOCATION (*expr_p)); + EXPR_LOCATION (*expr_p), ! returns_twice); if (t == GS_ERROR) ret = GS_ERROR; @@ -2553,7 +2573,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) { enum gimplify_status t; t = gimplify_arg (&CALL_EXPR_STATIC_CHAIN (*expr_p), pre_p, - EXPR_LOCATION (*expr_p)); + EXPR_LOCATION (*expr_p), ! returns_twice); if (t == GS_ERROR) ret = GS_ERROR; } @@ -3316,7 +3336,8 @@ prepare_gimple_addressable (tree *expr_p, gimple_seq *seq_p) expr_p = &TREE_OPERAND (*expr_p, 0); if (is_gimple_reg (*expr_p)) { - tree var = get_initialized_tmp_var (*expr_p, seq_p, NULL); + /* Do not allow an SSA name as the temporary. */ + tree var = get_initialized_tmp_var (*expr_p, seq_p, NULL, false); DECL_GIMPLE_REG_P (var) = 0; *expr_p = var; } @@ -4848,6 +4869,11 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, || TREE_ADDRESSABLE (TREE_TYPE (*to_p)) || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (*to_p))) != INTEGER_CST) gimple_call_set_lhs (call_stmt, *to_p); + else if (TREE_CODE (*to_p) == SSA_NAME) + /* The above is somewhat premature, avoid ICEing later for a + SSA name w/o a definition. We may have uses in the GIMPLE IL. + ??? This doesn't make it a default-def. */ + SSA_NAME_DEF_STMT (*to_p) = gimple_build_nop (); assign = call_stmt; } else @@ -4861,7 +4887,8 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (gimplify_ctxp->into_ssa && is_gimple_reg (*to_p)) { /* We should have got an SSA name from the start. */ - gcc_assert (TREE_CODE (*to_p) == SSA_NAME); + gcc_assert (TREE_CODE (*to_p) == SSA_NAME + || ! gimple_in_ssa_p (cfun)); } gimplify_seq_add_stmt (pre_p, assign); @@ -4994,7 +5021,9 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) val = NULL; } else - val = get_initialized_tmp_var (val, pre_p, post_p); + /* The temporary may not be an SSA name as later abnormal and EH + control flow may invalidate use/def domination. */ + val = get_initialized_tmp_var (val, pre_p, post_p, false); TREE_OPERAND (*expr_p, 0) = val; SAVE_EXPR_RESOLVED_P (*expr_p) = 1; @@ -6653,7 +6682,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, { tree type = TREE_TYPE (decl); if (gimplify_expr (&TYPE_MAX_VALUE (TYPE_DOMAIN (type)), pre_p, - NULL, is_gimple_val, fb_rvalue) == GS_ERROR) + NULL, is_gimple_val, fb_rvalue, false) + == GS_ERROR) { remove = true; break; @@ -6668,7 +6698,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, if (TREE_CODE (decl) == POINTER_PLUS_EXPR) { if (gimplify_expr (&TREE_OPERAND (decl, 1), pre_p, - NULL, is_gimple_val, fb_rvalue) + NULL, is_gimple_val, fb_rvalue, false) == GS_ERROR) { remove = true; @@ -6865,7 +6895,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, && TREE_CODE (OMP_CLAUSE_SIZE (c)) != INTEGER_CST) { OMP_CLAUSE_SIZE (c) - = get_initialized_tmp_var (OMP_CLAUSE_SIZE (c), pre_p, NULL); + = get_initialized_tmp_var (OMP_CLAUSE_SIZE (c), pre_p, NULL, + false); omp_add_variable (ctx, OMP_CLAUSE_SIZE (c), GOVD_FIRSTPRIVATE | GOVD_SEEN); } @@ -8609,7 +8640,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { TREE_OPERAND (t, 1) = get_initialized_tmp_var (TREE_OPERAND (t, 1), - pre_p, NULL); + pre_p, NULL, false); tree c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); OMP_CLAUSE_DECL (c) = TREE_OPERAND (t, 1); @@ -8624,7 +8655,8 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) TREE_OPERAND (t, 1) = get_initialized_tmp_var (TREE_OPERAND (t, 1), gimple_seq_empty_p (for_pre_body) - ? pre_p : &for_pre_body, NULL); + ? pre_p : &for_pre_body, NULL, + false); tree c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); OMP_CLAUSE_DECL (c) = TREE_OPERAND (t, 1); @@ -8646,7 +8678,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { gimple_seq *seq = gimple_seq_empty_p (for_pre_body) ? pre_p : &for_pre_body; - *tp = get_initialized_tmp_var (*tp, seq, NULL); + *tp = get_initialized_tmp_var (*tp, seq, NULL, false); tree c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); OMP_CLAUSE_DECL (c) = *tp; @@ -8982,7 +9014,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) var = decl; tret = gimplify_expr (&TREE_OPERAND (t, 1), &for_pre_body, NULL, - is_gimple_val, fb_rvalue); + is_gimple_val, fb_rvalue, false); ret = MIN (ret, tret); if (ret == GS_ERROR) return ret; @@ -8993,7 +9025,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) gcc_assert (TREE_OPERAND (t, 0) == decl); tret = gimplify_expr (&TREE_OPERAND (t, 1), &for_pre_body, NULL, - is_gimple_val, fb_rvalue); + is_gimple_val, fb_rvalue, false); ret = MIN (ret, tret); /* Handle OMP_FOR_INCR. */ @@ -9060,7 +9092,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) } tret = gimplify_expr (&TREE_OPERAND (t, 1), &for_pre_body, NULL, - is_gimple_val, fb_rvalue); + is_gimple_val, fb_rvalue, false); ret = MIN (ret, tret); if (c) { @@ -9076,7 +9108,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { tret = gimplify_expr (&OMP_CLAUSE_LINEAR_STEP (c), &for_pre_body, NULL, - is_gimple_val, fb_rvalue); + is_gimple_val, fb_rvalue, false); ret = MIN (ret, tret); } } @@ -9530,7 +9562,7 @@ optimize_target_teams (tree target, gimple_seq *pre_p) } *p = expr; gimplify_omp_ctxp = gimplify_omp_ctxp->outer_context; - if (gimplify_expr (p, pre_p, NULL, is_gimple_val, fb_rvalue) + if (gimplify_expr (p, pre_p, NULL, is_gimple_val, fb_rvalue, false) == GS_ERROR) { gimplify_omp_ctxp = target_ctx; @@ -10248,7 +10280,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, required. */ if (fallback == fb_lvalue) { - *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p); + *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p, false); mark_addressable (*expr_p); ret = GS_OK; } @@ -10263,7 +10295,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, required. */ if (fallback == fb_lvalue) { - *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p); + *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p, false); mark_addressable (*expr_p); ret = GS_OK; } @@ -10558,7 +10590,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, required. */ else if (fallback == fb_lvalue) { - *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p); + *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p, false); mark_addressable (*expr_p); ret = GS_OK; } @@ -11256,6 +11288,35 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, return ret; } +/* Like gimplify_expr but make sure the gimplified result is not itself + a SSA name (but a decl if it were). Temporaries required by + evaluating *EXPR_P may be still SSA names. */ + +static enum gimplify_status +gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, + bool (*gimple_test_f) (tree), fallback_t fallback, + bool allow_ssa) +{ + bool was_ssa_name_p = TREE_CODE (*expr_p) == SSA_NAME; + enum gimplify_status ret = gimplify_expr (expr_p, pre_p, post_p, + gimple_test_f, fallback); + if (! allow_ssa + && TREE_CODE (*expr_p) == SSA_NAME) + { + tree name = *expr_p; + if (was_ssa_name_p) + *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false); + else + { + /* Avoid the extra copy if possible. */ + *expr_p = create_tmp_reg (TREE_TYPE (name)); + gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p); + release_ssa_name (name); + } + } + return ret; +} + /* Look through TYPE for variable-sized objects and gimplify each such size that we find. Add to LIST_P any statements generated. */ @@ -11378,7 +11439,9 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p) *expr_p = unshare_expr (expr); - gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue); + /* SSA names in decl/type fields are a bad idea - they'll get reclaimed + if the def vanishes. */ + gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue, false); } /* Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node @@ -11396,12 +11459,14 @@ gimplify_body (tree fndecl, bool do_parms) timevar_push (TV_TREE_GIMPLIFY); + init_tree_ssa (cfun); + /* Initialize for optimize_insn_for_s{ize,peed}_p possibly called during gimplification. */ default_rtl_profile (); gcc_assert (gimplify_ctxp == NULL); - push_gimplify_context (); + push_gimplify_context (true); if (flag_openacc || flag_openmp) { diff --git a/gcc/gimplify.h b/gcc/gimplify.h index fd003a0e127..27823e6bb99 100644 --- a/gcc/gimplify.h +++ b/gcc/gimplify.h @@ -57,7 +57,8 @@ extern gbind *gimple_current_bind_expr (void); extern vec gimple_bind_expr_stack (void); extern void gimplify_and_add (tree, gimple_seq *); extern tree get_formal_tmp_var (tree, gimple_seq *); -extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *); +extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *, + bool = true); extern void declare_vars (tree, gimple *, bool); extern void gimple_add_tmp_var (tree); extern void gimple_add_tmp_var_fn (struct function *, tree); @@ -77,7 +78,8 @@ extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *, extern void gimplify_type_sizes (tree, gimple_seq *); extern void gimplify_one_sizepos (tree *, gimple_seq *); extern gbind *gimplify_body (tree, bool); -extern enum gimplify_status gimplify_arg (tree *, gimple_seq *, location_t); +extern enum gimplify_status gimplify_arg (tree *, gimple_seq *, location_t, + bool = true); extern void gimplify_function_tree (tree); extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *, gimple_seq *); diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 048c8798ad5..c9600fb6d33 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2570,6 +2570,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy) it afterward. */ push_struct_function (decl); cfun->function_end_locus = gimple_location (ctx->stmt); + init_tree_ssa (cfun); pop_cfun (); } @@ -13672,6 +13673,7 @@ grid_expand_target_grid_body (struct omp_region *target) DECL_INITIAL (kern_fndecl) = fniniblock; push_struct_function (kern_fndecl); cfun->function_end_locus = gimple_location (tgt_stmt); + init_tree_ssa (cfun); pop_cfun (); tree old_parm_decl = DECL_ARGUMENTS (kern_fndecl); diff --git a/gcc/passes.def b/gcc/passes.def index 834fea28aa6..0e55829fe62 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -54,7 +54,6 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_build_ssa_passes); PUSH_INSERT_PASSES_WITHIN (pass_build_ssa_passes) NEXT_PASS (pass_fixup_cfg); - NEXT_PASS (pass_init_datastructures); NEXT_PASS (pass_build_ssa); NEXT_PASS (pass_warn_nonnull_compare); NEXT_PASS (pass_ubsan); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a898688fc5..2ccbfa6d366 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2016-05-03 Richard Biener + + * gcc.dg/pr30172-1.c: Adjust. + * gcc.dg/pr63743.c: Likewise. + * gcc.dg/tm/pr51696.c: Likewise. + * c-c++-common/tm/safe-1.c: Likewise. + * gcc.dg/tree-prof/val-prof-3.c: Likewise. + * gcc.dg/plugin/self-assign-test-1.c: XFAIL case that needs CSE. + * g++.dg/plugin/self-assign-test-1.C: Likewise. + * g++.dg/plugin/self-assign-test-2.C: Likewise. + 2016-05-03 Jakub Jelinek PR rtl-optimization/70467 diff --git a/gcc/testsuite/c-c++-common/tm/safe-1.c b/gcc/testsuite/c-c++-common/tm/safe-1.c index b2a43530575..4a81a78c396 100644 --- a/gcc/testsuite/c-c++-common/tm/safe-1.c +++ b/gcc/testsuite/c-c++-common/tm/safe-1.c @@ -35,9 +35,9 @@ foo(void) /* tu(); */ (*ps)(); - (*pc)(); /* { dg-error "unsafe function call" } */ - (*pi)(); /* { dg-error "unsafe function call" } */ - (*pu)(); /* { dg-error "unsafe function call" } */ + (*pc)(); /* { dg-error "unsafe indirect function call" } */ + (*pi)(); /* { dg-error "unsafe indirect function call" } */ + (*pu)(); /* { dg-error "unsafe indirect function call" } */ asm(""); /* { dg-error "asm not allowed" } */ asm("" : "=g"(i)); /* { dg-error "asm not allowed" } */ @@ -57,10 +57,10 @@ bar(void) tm(); (*ps)(); - (*pc)(); /* { dg-error "unsafe function call" } */ - (*pi)(); /* { dg-error "unsafe function call" } */ + (*pc)(); /* { dg-error "unsafe indirect function call" } */ + (*pi)(); /* { dg-error "unsafe indirect function call" } */ (*pm)(); - (*pu)(); /* { dg-error "unsafe function call" } */ + (*pu)(); /* { dg-error "unsafe indirect function call" } */ asm(""); /* { dg-error "asm not allowed" } */ asm("" : "=g"(i)); /* { dg-error "asm not allowed" } */ diff --git a/gcc/testsuite/g++.dg/plugin/self-assign-test-1.C b/gcc/testsuite/g++.dg/plugin/self-assign-test-1.C index 607381fb403..95d39dd0ce6 100644 --- a/gcc/testsuite/g++.dg/plugin/self-assign-test-1.C +++ b/gcc/testsuite/g++.dg/plugin/self-assign-test-1.C @@ -44,7 +44,7 @@ int func() foo = foo; // { dg-warning "assigned to itself" } foo.setA(5); bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" } - bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" } + bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" "" { xfail *-*-* } } y = x; x = y; } diff --git a/gcc/testsuite/g++.dg/plugin/self-assign-test-2.C b/gcc/testsuite/g++.dg/plugin/self-assign-test-2.C index 35e1fb8f893..da963c42db2 100644 --- a/gcc/testsuite/g++.dg/plugin/self-assign-test-2.C +++ b/gcc/testsuite/g++.dg/plugin/self-assign-test-2.C @@ -44,7 +44,7 @@ int func() foo = foo; // { dg-bogus "assigned to itself" } foo.setA(5); bar_array[3].c_ = bar_array[3].c_; // { dg-warning "assigned to itself" } - bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" } + bar_array[x+g].b_ = bar_array[x+g].b_; // { dg-warning "self-assignment detected" "" { xfail *-*-* } } y = x; x = y; } diff --git a/gcc/testsuite/gcc.dg/fold-perm.c b/gcc/testsuite/gcc.dg/fold-perm.c index 9cfc2db36aa..0fa050eb292 100644 --- a/gcc/testsuite/gcc.dg/fold-perm.c +++ b/gcc/testsuite/gcc.dg/fold-perm.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-ccp1" } */ +/* { dg-options "-O -fdump-tree-fre1" } */ typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); @@ -14,6 +14,6 @@ void fun (veci *f, veci *g, veci *h, veci *i) *f = __builtin_shuffle (*f, *g, n); } -/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 3, 3, 0, 2 }" "ccp1" } } */ -/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 1, 1, 3, 2 }" "ccp1" } } */ -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 2 "ccp1" } } */ +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 3, 3, 0, 2 }" "fre1" } } */ +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 1, 1, 3, 2 }" "fre1" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 2 "fre1" } } */ diff --git a/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c b/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c index f6dc5240f1e..28c14dd762a 100644 --- a/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c +++ b/gcc/testsuite/gcc.dg/plugin/self-assign-test-1.c @@ -16,7 +16,7 @@ int main() static int y; struct Bar b_array[5]; - b_array[x+g].b_ = b_array[x+g].b_; /* { dg-warning "self-assignment detected" } */ + b_array[x+g].b_ = b_array[x+g].b_; /* { dg-warning "self-assignment detected" "" { xfail *-*-* } } */ g = g; /* { dg-warning "assigned to itself" } */ y = y; /* { dg-warning "assigned to itself" } */ bar->b_ = bar->b_; /* { dg-warning "assigned to itself" } */ diff --git a/gcc/testsuite/gcc.dg/pr30172-1.c b/gcc/testsuite/gcc.dg/pr30172-1.c index 015b558d067..ee6efdeebb8 100644 --- a/gcc/testsuite/gcc.dg/pr30172-1.c +++ b/gcc/testsuite/gcc.dg/pr30172-1.c @@ -10,5 +10,5 @@ _Complex double test5 (double x, double y) { return (x + y * 1.i) * -1.i; } /* { dg-final { scan-tree-dump "COMPLEX_EXPR " "gimple" } } */ /* { dg-final { scan-tree-dump "COMPLEX_EXPR <1.0e\\+0, x>" "gimple" } } */ /* { dg-final { scan-tree-dump "COMPLEX_EXPR " "gimple" } } */ -/* { dg-final { scan-tree-dump "D.* = -y;\n.*COMPLEX_EXPR " "gimple" } } */ -/* { dg-final { scan-tree-dump "D.* = -x;\n.*COMPLEX_EXPR " "gimple" } } */ +/* { dg-final { scan-tree-dump " = -y;\n.*COMPLEX_EXPR <\[^,\]*, x>" "gimple" } } */ +/* { dg-final { scan-tree-dump " = -x;\n.*COMPLEX_EXPR compare(); /* { dg-error "unsafe indirect function call" } */ - compare(); /* { dg-error "unsafe function call" } */ + compare(); /* { dg-error "unsafe indirect function call" } */ } diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c index 6da88a898f1..9a600c334ee 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c @@ -27,5 +27,5 @@ main () /* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */ /* This is part of code checking that n is greater than the divisor so we are sure that it didn't get optimized out. */ -/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */ +/* { dg-final-use { scan-tree-dump "if \\(_\[0-9\]* \\< n_\[0-9\]*" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c index a566f1ee6a4..1dabd39e569 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c @@ -84,5 +84,5 @@ test_8 (int code) the negated code == 22 compare to code != 22 first. It turns out if we do that we even generate better code on x86 at least. */ -/* { dg-final { scan-tree-dump-times "simplified to if \\\(\[^ ]* <" 4 "forwprop1"} } */ +/* { dg-final { scan-tree-dump-times "simplified to if \\\(\[^ ]* \[<>\]" 4 "forwprop1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-43.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-43.c index 1a837666c25..89cddcd7486 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-43.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-43.c @@ -1,6 +1,6 @@ /* PR tree-optimization/64193 */ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-fre1-details" } */ +/* { dg-options "-O -fdump-tree-fre1" } */ double T,T2,E1[5]; int J; @@ -24,5 +24,4 @@ L10: /* We should remove 15 dead loads and some related stmts, fully propagating their replacements with exactly 4 loads and 4 stores from/to E remaining. */ -/* { dg-final { scan-tree-dump-times "Removing dead stmt" 19 "fre1" } } */ -/* { dg-final { scan-tree-dump-not "Not changing value number" "fre1" } } */ +/* { dg-final { scan-tree-dump-times "MEM" 8 "fre1" } } */ diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index 500071f94f1..2a6e101e9f2 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -726,7 +726,8 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p, "atomic transaction", fn); else { - if (!DECL_P (fn) || DECL_NAME (fn)) + if ((!DECL_P (fn) || DECL_NAME (fn)) + && TREE_CODE (fn) != SSA_NAME) error_at (gimple_location (stmt), "unsafe function call %qE within " "atomic transaction", fn); @@ -744,7 +745,8 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p, "% function", fn); else { - if (!DECL_P (fn) || DECL_NAME (fn)) + if ((!DECL_P (fn) || DECL_NAME (fn)) + && TREE_CODE (fn) != SSA_NAME) error_at (gimple_location (stmt), "unsafe function call %qE within " "% function", fn); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 4ce1eaa32b0..65737028843 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2135,13 +2135,8 @@ remove_bb (basic_block bb) } else { - /* Release SSA definitions if we are in SSA. Note that we - may be called when not in SSA. For example, - final_cleanup calls this function via - cleanup_tree_cfg. */ - if (gimple_in_ssa_p (cfun)) - release_defs (stmt); - + /* Release SSA definitions. */ + release_defs (stmt); gsi_remove (&i, true); } diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 015a9074b78..19f202e5371 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2456,8 +2456,9 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count) if (src_cfun->gimple_df) { init_tree_ssa (cfun); - cfun->gimple_df->in_ssa_p = true; - init_ssa_operands (cfun); + cfun->gimple_df->in_ssa_p = src_cfun->gimple_df->in_ssa_p; + if (cfun->gimple_df->in_ssa_p) + init_ssa_operands (cfun); } } @@ -5119,10 +5120,21 @@ replace_locals_op (tree *tp, int *walk_subtrees, void *data) tree *n; tree expr = *tp; + /* For recursive invocations this is no longer the LHS itself. */ + bool is_lhs = wi->is_lhs; + wi->is_lhs = false; + + if (TREE_CODE (expr) == SSA_NAME) + { + *tp = remap_ssa_name (*tp, id); + *walk_subtrees = 0; + if (is_lhs) + SSA_NAME_DEF_STMT (*tp) = gsi_stmt (wi->gsi); + } /* Only a local declaration (variable or label). */ - if ((TREE_CODE (expr) == VAR_DECL - && !TREE_STATIC (expr)) - || TREE_CODE (expr) == LABEL_DECL) + else if ((TREE_CODE (expr) == VAR_DECL + && !TREE_STATIC (expr)) + || TREE_CODE (expr) == LABEL_DECL) { /* Lookup the declaration. */ n = st->get (expr); @@ -5262,6 +5274,7 @@ copy_gimple_seq_and_replace_locals (gimple_seq seq) memset (&id, 0, sizeof (id)); id.src_fn = current_function_decl; id.dst_fn = current_function_decl; + id.src_cfun = cfun; id.decl_map = new hash_map; id.debug_map = NULL; diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 8dfcc333c93..f83cad2e936 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -666,6 +666,8 @@ mark_def_sites (basic_block bb, gimple *stmt, bitmap kills) FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) { tree sym = USE_FROM_PTR (use_p); + if (TREE_CODE (sym) == SSA_NAME) + continue; gcc_checking_assert (DECL_P (sym)); if (!bitmap_bit_p (kills, DECL_UID (sym))) set_livein_block (sym, bb); @@ -676,6 +678,8 @@ mark_def_sites (basic_block bb, gimple *stmt, bitmap kills) each def to the set of killed symbols. */ FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS) { + if (TREE_CODE (def) == SSA_NAME) + continue; gcc_checking_assert (DECL_P (def)); set_def_block (def, bb, false); bitmap_set_bit (kills, DECL_UID (def)); @@ -1310,6 +1314,8 @@ rewrite_stmt (gimple_stmt_iterator *si) FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) { tree var = USE_FROM_PTR (use_p); + if (TREE_CODE (var) == SSA_NAME) + continue; gcc_checking_assert (DECL_P (var)); SET_USE (use_p, get_reaching_def (var)); } @@ -1323,6 +1329,8 @@ rewrite_stmt (gimple_stmt_iterator *si) tree name; tree tracked_var; + if (TREE_CODE (var) == SSA_NAME) + continue; gcc_checking_assert (DECL_P (var)); if (gimple_clobber_p (stmt) diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index cd8c3399f9f..66e103ae37e 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -506,7 +506,6 @@ extern ipa_opt_pass_d *make_pass_ipa_comdats (gcc::context *ctxt); extern gimple_opt_pass *make_pass_cleanup_cfg_post_optimizing (gcc::context *ctxt); -extern gimple_opt_pass *make_pass_init_datastructures (gcc::context *ctxt); extern gimple_opt_pass *make_pass_fixup_cfg (gcc::context *ctxt); extern gimple_opt_pass *make_pass_backprop (gcc::context *ctxt); diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index c4e27f1cfe9..ae120a8ff95 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -273,6 +273,7 @@ get_default_value (tree var) can assume initially that it is UNDEFINED, otherwise we must consider it VARYING. */ if (!virtual_operand_p (var) + && SSA_NAME_VAR (var) && TREE_CODE (SSA_NAME_VAR (var)) == VAR_DECL) val.lattice_val = UNDEFINED; else diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 6a16d268e69..0a59dd209ff 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1051,62 +1051,6 @@ init_tree_ssa (struct function *fn) init_ssanames (fn, 0); } -/* Do the actions required to initialize internal data structures used - in tree-ssa optimization passes. */ - -static unsigned int -execute_init_datastructures (void) -{ - /* Allocate hash tables, arrays and other structures. */ - gcc_assert (!cfun->gimple_df); - init_tree_ssa (cfun); - return 0; -} - -namespace { - -const pass_data pass_data_init_datastructures = -{ - GIMPLE_PASS, /* type */ - "*init_datastructures", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - TV_NONE, /* tv_id */ - PROP_cfg, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ -}; - -class pass_init_datastructures : public gimple_opt_pass -{ -public: - pass_init_datastructures (gcc::context *ctxt) - : gimple_opt_pass (pass_data_init_datastructures, ctxt) - {} - - /* opt_pass methods: */ - virtual bool gate (function *fun) - { - /* Do nothing for funcions that was produced already in SSA form. */ - return !(fun->curr_properties & PROP_ssa); - } - - virtual unsigned int execute (function *) - { - return execute_init_datastructures (); - } - -}; // class pass_init_datastructures - -} // anon namespace - -gimple_opt_pass * -make_pass_init_datastructures (gcc::context *ctxt) -{ - return new pass_init_datastructures (ctxt); -} - /* Deallocate memory associated with SSA data structures for FNDECL. */ void diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index b72c7cb55b1..91a8f97ebea 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -740,10 +740,6 @@ release_defs (gimple *stmt) tree def; ssa_op_iter iter; - /* Make sure that we are in SSA. Otherwise, operand cache may point - to garbage. */ - gcc_assert (gimple_in_ssa_p (cfun)); - FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS) if (TREE_CODE (def) == SSA_NAME) release_ssa_name (def); -- 2.30.2