aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-12-21 06:57:41 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-12-21 06:57:41 +0000
commitf37fac2b74df114c5b3e9c8a3be2cad9acd3f4ca (patch)
treeebd8f2d136ae51379031e2596095f05826868563 /gcc/dwarf2out.c
parent5b9bbb630de43db527acf5e5a80c0a3dd446e0d9 (diff)
downloadgcc-f37fac2b74df114c5b3e9c8a3be2cad9acd3f4ca.zip
gcc-f37fac2b74df114c5b3e9c8a3be2cad9acd3f4ca.tar.gz
gcc-f37fac2b74df114c5b3e9c8a3be2cad9acd3f4ca.tar.bz2
poly_int: get_inner_reference & co.
This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255914
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1fa76d0..018f512 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -16700,7 +16700,7 @@ loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev,
loc_descr_context *context)
{
tree obj, offset;
- HOST_WIDE_INT bitsize, bitpos, bytepos;
+ poly_int64 bitsize, bitpos, bytepos;
machine_mode mode;
int unsignedp, reversep, volatilep = 0;
dw_loc_list_ref list_ret = NULL, list_ret1 = NULL;
@@ -16709,7 +16709,7 @@ loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev,
&bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
STRIP_NOPS (obj);
- if (bitpos % BITS_PER_UNIT)
+ if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos))
{
expansion_failed (loc, NULL_RTX, "bitfield access");
return 0;
@@ -16720,7 +16720,7 @@ loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev,
NULL_RTX, "no indirect ref in inner refrence");
return 0;
}
- if (!offset && !bitpos)
+ if (!offset && known_eq (bitpos, 0))
list_ret = loc_list_from_tree (TREE_OPERAND (obj, 0), toplev ? 2 : 1,
context);
else if (toplev
@@ -16742,12 +16742,11 @@ loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev,
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_plus, 0, 0));
}
- bytepos = bitpos / BITS_PER_UNIT;
- if (bytepos > 0)
+ HOST_WIDE_INT value;
+ if (bytepos.is_constant (&value) && value > 0)
add_loc_descr_to_each (list_ret,
- new_loc_descr (DW_OP_plus_uconst,
- bytepos, 0));
- else if (bytepos < 0)
+ new_loc_descr (DW_OP_plus_uconst, value, 0));
+ else if (maybe_ne (bytepos, 0))
loc_list_plus_const (list_ret, bytepos);
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_stack_value, 0, 0));
@@ -17717,7 +17716,7 @@ loc_list_from_tree_1 (tree loc, int want_address,
case IMAGPART_EXPR:
{
tree obj, offset;
- HOST_WIDE_INT bitsize, bitpos, bytepos;
+ poly_int64 bitsize, bitpos, bytepos;
machine_mode mode;
int unsignedp, reversep, volatilep = 0;
@@ -17728,13 +17727,15 @@ loc_list_from_tree_1 (tree loc, int want_address,
list_ret = loc_list_from_tree_1 (obj,
want_address == 2
- && !bitpos && !offset ? 2 : 1,
+ && known_eq (bitpos, 0)
+ && !offset ? 2 : 1,
context);
/* TODO: We can extract value of the small expression via shifting even
for nonzero bitpos. */
if (list_ret == 0)
return 0;
- if (bitpos % BITS_PER_UNIT != 0 || bitsize % BITS_PER_UNIT != 0)
+ if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
+ || !multiple_p (bitsize, BITS_PER_UNIT))
{
expansion_failed (loc, NULL_RTX,
"bitfield access");
@@ -17753,10 +17754,11 @@ loc_list_from_tree_1 (tree loc, int want_address,
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus, 0, 0));
}
- bytepos = bitpos / BITS_PER_UNIT;
- if (bytepos > 0)
- add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus_uconst, bytepos, 0));
- else if (bytepos < 0)
+ HOST_WIDE_INT value;
+ if (bytepos.is_constant (&value) && value > 0)
+ add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus_uconst,
+ value, 0));
+ else if (maybe_ne (bytepos, 0))
loc_list_plus_const (list_ret, bytepos);
have_address = 1;
@@ -19286,8 +19288,9 @@ fortran_common (tree decl, HOST_WIDE_INT *value)
{
tree val_expr, cvar;
machine_mode mode;
- HOST_WIDE_INT bitsize, bitpos;
+ poly_int64 bitsize, bitpos;
tree offset;
+ HOST_WIDE_INT cbitpos;
int unsignedp, reversep, volatilep = 0;
/* If the decl isn't a VAR_DECL, or if it isn't static, or if
@@ -19310,7 +19313,10 @@ fortran_common (tree decl, HOST_WIDE_INT *value)
if (cvar == NULL_TREE
|| !VAR_P (cvar)
|| DECL_ARTIFICIAL (cvar)
- || !TREE_PUBLIC (cvar))
+ || !TREE_PUBLIC (cvar)
+ /* We don't expect to have to cope with variable offsets,
+ since at present all static data must have a constant size. */
+ || !bitpos.is_constant (&cbitpos))
return NULL_TREE;
*value = 0;
@@ -19320,8 +19326,8 @@ fortran_common (tree decl, HOST_WIDE_INT *value)
return NULL_TREE;
*value = tree_to_shwi (offset);
}
- if (bitpos != 0)
- *value += bitpos / BITS_PER_UNIT;
+ if (cbitpos != 0)
+ *value += cbitpos / BITS_PER_UNIT;
return cvar;
}