diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
commit | a926878ddbd5a98b272c22171ce58663fc04c3e0 (patch) | |
tree | 86af256e5d9a9c06263c00adc90e5fe348008c43 /gcc/tree-ssa-ccp.c | |
parent | 542730f087133690b47e036dfd43eb0db8a650ce (diff) | |
parent | 07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff) | |
download | gcc-a926878ddbd5a98b272c22171ce58663fc04c3e0.zip gcc-a926878ddbd5a98b272c22171ce58663fc04c3e0.tar.gz gcc-a926878ddbd5a98b272c22171ce58663fc04c3e0.tar.bz2 |
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 91 |
1 files changed, 55 insertions, 36 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index be6647d..65dffe0 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -306,6 +306,9 @@ get_default_value (tree var) { val.lattice_val = CONSTANT; val.value = value; + widest_int ipa_value = wi::to_widest (value); + /* Unknown bits from IPA CP must be equal to zero. */ + gcc_assert (wi::bit_and (ipa_value, mask) == 0); val.mask = mask; if (nonzero_bits != -1) val.mask &= extend_mask (nonzero_bits, @@ -943,7 +946,7 @@ do_dbg_cnt (void) class ccp_folder : public substitute_and_fold_engine { public: - tree get_value (tree) FINAL OVERRIDE; + tree get_value (tree, gimple *) FINAL OVERRIDE; bool fold_stmt (gimple_stmt_iterator *) FINAL OVERRIDE; }; @@ -952,7 +955,7 @@ class ccp_folder : public substitute_and_fold_engine of calling member functions. */ tree -ccp_folder::get_value (tree op) +ccp_folder::get_value (tree op, gimple *stmt ATTRIBUTE_UNUSED) { return get_constant_value (op); } @@ -2002,6 +2005,7 @@ evaluate_stmt (gimple *stmt) case BUILT_IN_BSWAP16: case BUILT_IN_BSWAP32: case BUILT_IN_BSWAP64: + case BUILT_IN_BSWAP128: val = get_value_for_expr (gimple_call_arg (stmt, 0), true); if (val.lattice_val == UNDEFINED) break; @@ -2158,7 +2162,7 @@ gsi_prev_dom_bb_nondebug (gimple_stmt_iterator *i) gsi_prev_nondebug (i); while (gsi_end_p (*i)) { - dom = get_immediate_dominator (CDI_DOMINATORS, i->bb); + dom = get_immediate_dominator (CDI_DOMINATORS, gsi_bb (*i)); if (dom == NULL || dom == ENTRY_BLOCK_PTR_FOR_FN (cfun)) return; @@ -3539,43 +3543,58 @@ pass_post_ipa_warn::execute (function *fun) if (!is_gimple_call (stmt) || gimple_no_warning_p (stmt)) continue; - if (warn_nonnull) + tree fntype = gimple_call_fntype (stmt); + bitmap nonnullargs = get_nonnull_args (fntype); + if (!nonnullargs) + continue; + + tree fndecl = gimple_call_fndecl (stmt); + + for (unsigned i = 0; i < gimple_call_num_args (stmt); i++) { - bitmap nonnullargs - = get_nonnull_args (gimple_call_fntype (stmt)); - if (nonnullargs) + tree arg = gimple_call_arg (stmt, i); + if (TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE) + continue; + if (!integer_zerop (arg)) + continue; + if (!bitmap_empty_p (nonnullargs) + && !bitmap_bit_p (nonnullargs, i)) + continue; + + /* In C++ non-static member functions argument 0 refers + to the implicit this pointer. Use the same one-based + numbering for ordinary arguments. */ + unsigned argno = TREE_CODE (fntype) == METHOD_TYPE ? i : i + 1; + location_t loc = (EXPR_HAS_LOCATION (arg) + ? EXPR_LOCATION (arg) + : gimple_location (stmt)); + auto_diagnostic_group d; + if (argno == 0) { - for (unsigned i = 0; i < gimple_call_num_args (stmt); i++) - { - tree arg = gimple_call_arg (stmt, i); - if (TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE) - continue; - if (!integer_zerop (arg)) - continue; - if (!bitmap_empty_p (nonnullargs) - && !bitmap_bit_p (nonnullargs, i)) - continue; - - location_t loc = gimple_location (stmt); - auto_diagnostic_group d; - if (warning_at (loc, OPT_Wnonnull, - "%Gargument %u null where non-null " - "expected", stmt, i + 1)) - { - tree fndecl = gimple_call_fndecl (stmt); - if (fndecl && DECL_IS_BUILTIN (fndecl)) - inform (loc, "in a call to built-in function %qD", - fndecl); - else if (fndecl) - inform (DECL_SOURCE_LOCATION (fndecl), - "in a call to function %qD declared here", - fndecl); - - } - } - BITMAP_FREE (nonnullargs); + if (warning_at (loc, OPT_Wnonnull, + "%G%qs pointer null", stmt, "this") + && fndecl) + inform (DECL_SOURCE_LOCATION (fndecl), + "in a call to non-static member function %qD", + fndecl); + continue; } + + if (!warning_at (loc, OPT_Wnonnull, + "%Gargument %u null where non-null " + "expected", stmt, argno)) + continue; + + tree fndecl = gimple_call_fndecl (stmt); + if (fndecl && DECL_IS_BUILTIN (fndecl)) + inform (loc, "in a call to built-in function %qD", + fndecl); + else if (fndecl) + inform (DECL_SOURCE_LOCATION (fndecl), + "in a call to function %qD declared %qs", + fndecl, "nonnull"); } + BITMAP_FREE (nonnullargs); } } return 0; |