Hi, On Sun, 2014-03-23 at 12:15 +0100, Mark Wielaard wrote: > * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, > then represent the bound as normal constant value.
Since stage 1 opened up I would like to request approval again to push this. Patch rebased to current master attached. Previous discussion here: http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01192.html Thanks, Mark
commit 668472db0186f79c4e50c6e422c5e90f82017b16 Author: Mark Wielaard <m...@redhat.com> Date: Thu Mar 20 18:02:36 2014 +0100 dwarf2out: Use normal constant values in bound_info if possible. * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, then represent the bound as normal constant value. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2c127c..b1706ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-03-20 Mark Wielaard <m...@redhat.com> + + * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, + then represent the bound as normal constant value. + 2014-04-14 Paolo Carlini <paolo.carl...@oracle.com> * tree.h (TYPE_IDENTIFIER): Declare. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 721f761..7eef56c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -16203,21 +16203,29 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b && tree_to_shwi (bound) == dflt) ; - /* Otherwise represent the bound as an unsigned value with the - precision of its type. The precision and signedness of the - type will be necessary to re-interpret it unambiguously. */ - else if (prec < HOST_BITS_PER_WIDE_INT) + /* If HOST_WIDE_INT is big enough then represent the bound as + a constant value. Note that we need to make sure the type + is signed or unsigned. We cannot just add an unsigned + constant if the value itself is positive. Some DWARF + consumers will lookup the bounds type and then sign extend + any unsigned values found for signed types. This is only + for DW_AT_lower_bound, normally unsigned values + (DW_FORM_data[1248]) are assumed to not need + sign-extension. */ + else if (prec <= HOST_BITS_PER_WIDE_INT + || TREE_INT_CST_HIGH (bound) == 0) { - unsigned HOST_WIDE_INT mask - = ((unsigned HOST_WIDE_INT) 1 << prec) - 1; - add_AT_unsigned (subrange_die, bound_attr, - TREE_INT_CST_LOW (bound) & mask); + if (TYPE_UNSIGNED (TREE_TYPE (bound))) + add_AT_unsigned (subrange_die, bound_attr, + TREE_INT_CST_LOW (bound)); + else + add_AT_int (subrange_die, bound_attr, TREE_INT_CST_LOW (bound)); } - else if (prec == HOST_BITS_PER_WIDE_INT - || TREE_INT_CST_HIGH (bound) == 0) - add_AT_unsigned (subrange_die, bound_attr, - TREE_INT_CST_LOW (bound)); else + /* Otherwise represent the bound as an unsigned value with + the precision of its type. The precision and signedness + of the type will be necessary to re-interpret it + unambiguously. */ add_AT_double (subrange_die, bound_attr, TREE_INT_CST_HIGH (bound), TREE_INT_CST_LOW (bound)); }