diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-12-20 12:55:27 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-12-20 12:55:27 +0000 |
commit | 588db50c8cf2c2ea081b2be7c1c3bc5452cdef20 (patch) | |
tree | 3ba8f3c264cdf88b5f924b21cfa9f2ac097744d5 /gcc/tree-ssa-structalias.c | |
parent | 80d0198b739660305da17e12072578b7a99cb777 (diff) | |
download | gcc-588db50c8cf2c2ea081b2be7c1c3bc5452cdef20.zip gcc-588db50c8cf2c2ea081b2be7c1c3bc5452cdef20.tar.gz gcc-588db50c8cf2c2ea081b2be7c1c3bc5452cdef20.tar.bz2 |
poly_int: get_ref_base_and_extent
This patch changes the types of the bit offsets and sizes returned
by get_ref_base_and_extent to poly_int64.
There are some callers that can't sensibly operate on polynomial
offsets or handle cases where the offset and size aren't known
exactly. This includes the IPA devirtualisation code (since
there's no defined way of having vtables at variable offsets)
and some parts of the DWARF code. The patch therefore adds
a helper function get_ref_base_and_extent_hwi that either returns
exact HOST_WIDE_INT bit positions and sizes or returns a null
base to indicate failure.
2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* tree-dfa.h (get_ref_base_and_extent): Return the base, size and
max_size as poly_int64_pods rather than HOST_WIDE_INTs.
(get_ref_base_and_extent_hwi): Declare.
* tree-dfa.c (get_ref_base_and_extent): Return the base, size and
max_size as poly_int64_pods rather than HOST_WIDE_INTs.
(get_ref_base_and_extent_hwi): New function.
* cfgexpand.c (expand_debug_expr): Update call to
get_ref_base_and_extent.
* dwarf2out.c (add_var_loc_to_decl): Likewise.
* gimple-fold.c (get_base_constructor): Return the offset as a
poly_int64_pod rather than a HOST_WIDE_INT.
(fold_const_aggregate_ref_1): Track polynomial sizes and offsets.
* ipa-polymorphic-call.c
(ipa_polymorphic_call_context::set_by_invariant)
(extr_type_from_vtbl_ptr_store): Track polynomial offsets.
(ipa_polymorphic_call_context::ipa_polymorphic_call_context)
(check_stmt_for_type_change): Use get_ref_base_and_extent_hwi
rather than get_ref_base_and_extent.
(ipa_polymorphic_call_context::get_dynamic_type): Likewise.
* ipa-prop.c (ipa_load_from_parm_agg, compute_complex_assign_jump_func)
(get_ancestor_addr_info, determine_locally_known_aggregate_parts):
Likewise.
* ipa-param-manipulation.c (ipa_get_adjustment_candidate): Update
call to get_ref_base_and_extent.
* tree-sra.c (create_access, get_access_for_expr): Likewise.
* tree-ssa-alias.c (ao_ref_base, aliasing_component_refs_p)
(stmt_kills_ref_p): Likewise.
* tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Likewise.
* tree-ssa-scopedtables.c (avail_expr_hash, equal_mem_array_ref_p):
Likewise.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise.
Use get_ref_base_and_extent_hwi rather than get_ref_base_and_extent
when calling native_encode_expr.
* tree-ssa-structalias.c (get_constraint_for_component_ref): Update
call to get_ref_base_and_extent.
(do_structure_copy): Use get_ref_base_and_extent_hwi rather than
get_ref_base_and_extent.
* var-tracking.c (track_expr_p): Likewise.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r255886
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r-- | gcc/tree-ssa-structalias.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 89135ea..243cc46 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3191,9 +3191,9 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results, bool address_p, bool lhs_p) { tree orig_t = t; - HOST_WIDE_INT bitsize = -1; - HOST_WIDE_INT bitmaxsize = -1; - HOST_WIDE_INT bitpos; + poly_int64 bitsize = -1; + poly_int64 bitmaxsize = -1; + poly_int64 bitpos; bool reverse; tree forzero; @@ -3255,8 +3255,8 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results, ignore this constraint. When we handle pointer subtraction, we may have to do something cute here. */ - if ((unsigned HOST_WIDE_INT)bitpos < get_varinfo (result.var)->fullsize - && bitmaxsize != 0) + if (maybe_lt (poly_uint64 (bitpos), get_varinfo (result.var)->fullsize) + && maybe_ne (bitmaxsize, 0)) { /* It's also not true that the constraint will actually start at the right offset, it may start in some padding. We only care about @@ -3268,8 +3268,8 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results, cexpr.offset = 0; for (curr = get_varinfo (cexpr.var); curr; curr = vi_next (curr)) { - if (ranges_overlap_p (curr->offset, curr->size, - bitpos, bitmaxsize)) + if (ranges_maybe_overlap_p (poly_int64 (curr->offset), + curr->size, bitpos, bitmaxsize)) { cexpr.var = curr->id; results->safe_push (cexpr); @@ -3302,7 +3302,7 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results, results->safe_push (cexpr); } } - else if (bitmaxsize == 0) + else if (known_eq (bitmaxsize, 0)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Access to zero-sized part of variable, " @@ -3317,13 +3317,15 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results, /* If we do not know exactly where the access goes say so. Note that only for non-structure accesses we know that we access at most one subfiled of any variable. */ - if (bitpos == -1 - || bitsize != bitmaxsize + HOST_WIDE_INT const_bitpos; + if (!bitpos.is_constant (&const_bitpos) + || const_bitpos == -1 + || maybe_ne (bitsize, bitmaxsize) || AGGREGATE_TYPE_P (TREE_TYPE (orig_t)) || result.offset == UNKNOWN_OFFSET) result.offset = UNKNOWN_OFFSET; else - result.offset += bitpos; + result.offset += const_bitpos; } else if (result.type == ADDRESSOF) { @@ -3660,14 +3662,17 @@ do_structure_copy (tree lhsop, tree rhsop) && (rhsp->type == SCALAR || rhsp->type == ADDRESSOF)) { - HOST_WIDE_INT lhssize, lhsmaxsize, lhsoffset; - HOST_WIDE_INT rhssize, rhsmaxsize, rhsoffset; + HOST_WIDE_INT lhssize, lhsoffset; + HOST_WIDE_INT rhssize, rhsoffset; bool reverse; unsigned k = 0; - get_ref_base_and_extent (lhsop, &lhsoffset, &lhssize, &lhsmaxsize, - &reverse); - get_ref_base_and_extent (rhsop, &rhsoffset, &rhssize, &rhsmaxsize, - &reverse); + if (!get_ref_base_and_extent_hwi (lhsop, &lhsoffset, &lhssize, &reverse) + || !get_ref_base_and_extent_hwi (rhsop, &rhsoffset, &rhssize, + &reverse)) + { + process_all_all_constraints (lhsc, rhsc); + return; + } for (j = 0; lhsc.iterate (j, &lhsp);) { varinfo_t lhsv, rhsv; |