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/gimple-fold.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/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 285ece2..100e013 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -6333,10 +6333,10 @@ gimple_fold_stmt_to_constant (gimple *stmt, tree (*valueize) (tree)) is not explicitly available, but it is known to be zero such as 'static const int a;'. */ static tree -get_base_constructor (tree base, HOST_WIDE_INT *bit_offset, +get_base_constructor (tree base, poly_int64_pod *bit_offset, tree (*valueize)(tree)) { - HOST_WIDE_INT bit_offset2, size, max_size; + poly_int64 bit_offset2, size, max_size; bool reverse; if (TREE_CODE (base) == MEM_REF) @@ -6388,7 +6388,7 @@ get_base_constructor (tree base, HOST_WIDE_INT *bit_offset, case COMPONENT_REF: base = get_ref_base_and_extent (base, &bit_offset2, &size, &max_size, &reverse); - if (max_size == -1 || size != max_size) + if (!known_size_p (max_size) || maybe_ne (size, max_size)) return NULL_TREE; *bit_offset += bit_offset2; return get_base_constructor (base, bit_offset, valueize); @@ -6599,7 +6599,7 @@ tree fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree)) { tree ctor, idx, base; - HOST_WIDE_INT offset, size, max_size; + poly_int64 offset, size, max_size; tree tem; bool reverse; @@ -6625,23 +6625,23 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree)) if (TREE_CODE (TREE_OPERAND (t, 1)) == SSA_NAME && valueize && (idx = (*valueize) (TREE_OPERAND (t, 1))) - && TREE_CODE (idx) == INTEGER_CST) + && poly_int_tree_p (idx)) { tree low_bound, unit_size; /* If the resulting bit-offset is constant, track it. */ if ((low_bound = array_ref_low_bound (t), - TREE_CODE (low_bound) == INTEGER_CST) + poly_int_tree_p (low_bound)) && (unit_size = array_ref_element_size (t), tree_fits_uhwi_p (unit_size))) { - offset_int woffset - = wi::sext (wi::to_offset (idx) - wi::to_offset (low_bound), + poly_offset_int woffset + = wi::sext (wi::to_poly_offset (idx) + - wi::to_poly_offset (low_bound), TYPE_PRECISION (TREE_TYPE (idx))); - if (wi::fits_shwi_p (woffset)) + if (woffset.to_shwi (&offset)) { - offset = woffset.to_shwi (); /* TODO: This code seems wrong, multiply then check to see if it fits. */ offset *= tree_to_uhwi (unit_size); @@ -6654,7 +6654,7 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree)) return build_zero_cst (TREE_TYPE (t)); /* Out of bound array access. Value is undefined, but don't fold. */ - if (offset < 0) + if (maybe_lt (offset, 0)) return NULL_TREE; /* We can not determine ctor. */ if (!ctor) @@ -6679,14 +6679,14 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree)) if (ctor == error_mark_node) return build_zero_cst (TREE_TYPE (t)); /* We do not know precise address. */ - if (max_size == -1 || max_size != size) + if (!known_size_p (max_size) || maybe_ne (max_size, size)) return NULL_TREE; /* We can not determine ctor. */ if (!ctor) return NULL_TREE; /* Out of bound array access. Value is undefined, but don't fold. */ - if (offset < 0) + if (maybe_lt (offset, 0)) return NULL_TREE; return fold_ctor_reference (TREE_TYPE (t), ctor, offset, size, |