diff options
author | Mark Wielaard <mjw@redhat.com> | 2014-04-17 10:36:21 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2014-04-17 10:36:21 +0000 |
commit | 79896351cbd1ba94a66b867694b335127ee72449 (patch) | |
tree | 02a6ce36888dc53bf3d9792ae15e9a33926c21d5 /gcc/dwarf2out.c | |
parent | 5a65129e4ea51ffa1a6720a0dbea7aeb78ab60fa (diff) | |
download | gcc-79896351cbd1ba94a66b867694b335127ee72449.zip gcc-79896351cbd1ba94a66b867694b335127ee72449.tar.gz gcc-79896351cbd1ba94a66b867694b335127ee72449.tar.bz2 |
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.
From-SVN: r209473
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 0cdb3dc..8caf940 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -16203,21 +16203,31 @@ 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. We need to choose a form based on + whether the type is signed or unsigned. We cannot just + call add_AT_unsigned if the value itself is positive + (add_AT_unsigned might add the unsigned value encoded as + DW_FORM_data[1248]). Some DWARF consumers will lookup the + bounds type and then sign extend any unsigned values found + for signed types. This is needed only for + DW_AT_{lower,upper}_bound, since for most other attributes, + consumers will treat DW_FORM_data[1248] as unsigned values, + regardless of the underlying type. */ + 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)); } |