diff options
Diffstat (limited to 'gcc/tree-ssa-ccp.cc')
-rw-r--r-- | gcc/tree-ssa-ccp.cc | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 8d2cbb3..f33cc04 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -298,7 +298,7 @@ get_default_value (tree var) { val.lattice_val = VARYING; val.mask = -1; - if (flag_tree_bit_ccp) + if (flag_tree_bit_ccp && !VECTOR_TYPE_P (TREE_TYPE (var))) { wide_int nonzero_bits = get_nonzero_bits (var); tree value; @@ -2491,11 +2491,11 @@ evaluate_stmt (gimple *stmt) is_constant = (val.lattice_val == CONSTANT); } + tree lhs = gimple_get_lhs (stmt); if (flag_tree_bit_ccp + && lhs && TREE_CODE (lhs) == SSA_NAME && !VECTOR_TYPE_P (TREE_TYPE (lhs)) && ((is_constant && TREE_CODE (val.value) == INTEGER_CST) - || !is_constant) - && gimple_get_lhs (stmt) - && TREE_CODE (gimple_get_lhs (stmt)) == SSA_NAME) + || !is_constant)) { tree lhs = gimple_get_lhs (stmt); wide_int nonzero_bits = get_nonzero_bits (lhs); @@ -2567,7 +2567,12 @@ insert_clobber_before_stack_restore (tree saved_val, tree var, { clobber = build_clobber (TREE_TYPE (var), CLOBBER_STORAGE_END); clobber_stmt = gimple_build_assign (var, clobber); - + /* Manually update the vdef/vuse here. */ + gimple_set_vuse (clobber_stmt, gimple_vuse (stmt)); + gimple_set_vdef (clobber_stmt, make_ssa_name (gimple_vop (cfun))); + gimple_set_vuse (stmt, gimple_vdef (clobber_stmt)); + SSA_NAME_DEF_STMT (gimple_vdef (clobber_stmt)) = clobber_stmt; + update_stmt (stmt); i = gsi_for_stmt (stmt); gsi_insert_before (&i, clobber_stmt, GSI_SAME_STMT); } @@ -3020,7 +3025,7 @@ do_ssa_ccp (bool nonzero_p) ccp_propagate.ssa_propagate (); if (ccp_finalize (nonzero_p || flag_ipa_bit_cp)) { - todo = (TODO_cleanup_cfg | TODO_update_ssa); + todo = TODO_cleanup_cfg; /* ccp_finalize does not preserve loop-closed ssa. */ loops_state_clear (LOOP_CLOSED_SSA); @@ -4624,17 +4629,24 @@ pass_post_ipa_warn::execute (function *fun) unsigned int idx = TREE_INT_CST_LOW (TREE_VALUE (args)) - 1; unsigned int idx2 = TREE_INT_CST_LOW (TREE_VALUE (TREE_CHAIN (args))) - 1; + unsigned int idx3 = idx2; + if (tree chain2 = TREE_CHAIN (TREE_CHAIN (args))) + idx3 = TREE_INT_CST_LOW (TREE_VALUE (chain2)) - 1; if (idx < gimple_call_num_args (stmt) - && idx2 < gimple_call_num_args (stmt)) + && idx2 < gimple_call_num_args (stmt) + && idx3 < gimple_call_num_args (stmt)) { tree arg = gimple_call_arg (stmt, idx); tree arg2 = gimple_call_arg (stmt, idx2); + tree arg3 = gimple_call_arg (stmt, idx3); if (TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE || !integer_zerop (arg) || !INTEGRAL_TYPE_P (TREE_TYPE (arg2)) + || !INTEGRAL_TYPE_P (TREE_TYPE (arg3)) || integer_zerop (arg2) + || integer_zerop (arg3) || ((TREE_CODE (fntype) == METHOD_TYPE || closure) - && (idx == 0 || idx2 == 0))) + && (idx == 0 || idx2 == 0 || idx3 == 0))) continue; if (!integer_nonzerop (arg2) && !tree_expr_nonzero_p (arg2)) @@ -4649,17 +4661,40 @@ pass_post_ipa_warn::execute (function *fun) if (range_includes_zero_p (vr)) continue; } + if (idx2 != idx3 + && !integer_nonzerop (arg3) + && !tree_expr_nonzero_p (arg3)) + { + if (TREE_CODE (arg3) != SSA_NAME || optimize < 2) + continue; + if (!ranger) + ranger = enable_ranger (cfun); + + int_range_max vr; + get_range_query (cfun)->range_of_expr (vr, arg3, stmt); + if (range_includes_zero_p (vr)) + continue; + } unsigned argno = idx + 1; unsigned argno2 = idx2 + 1; + unsigned argno3 = idx3 + 1; location_t loc = (EXPR_HAS_LOCATION (arg) ? EXPR_LOCATION (arg) : gimple_location (stmt)); auto_diagnostic_group d; - if (!warning_at (loc, OPT_Wnonnull, - "argument %u null where non-null " - "expected because argument %u is " - "nonzero", argno, argno2)) + if (idx2 != idx3) + { + if (!warning_at (loc, OPT_Wnonnull, + "argument %u null where non-null " + "expected because arguments %u and %u " + "are nonzero", argno, argno2, argno3)) + continue; + } + else if (!warning_at (loc, OPT_Wnonnull, + "argument %u null where non-null " + "expected because argument %u is " + "nonzero", argno, argno2)) continue; tree fndecl = gimple_call_fndecl (stmt); |