[PATCH] dwarf2out: Use normal constant values in bound_info if possible.
Mark Wielaard
mjw@redhat.com
Sun Mar 23 11:17:00 GMT 2014
* dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough,
then represent the bound as normal constant value.
---
gcc/ChangeLog | 5 +++++
gcc/dwarf2out.c | 32 ++++++++++++++++++++------------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3ab789a..8a31187 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-20 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough,
+ then represent the bound as normal constant value.
+
2014-03-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/60569
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2b584a5..9f8b3b0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -16198,21 +16198,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));
}
--
1.7.1
More information about the Gcc-patches
mailing list