@@ -3259,7 +3259,7 @@ static HOST_WIDE_INT field_byte_offset (const_tree);
static void add_AT_location_description (dw_die_ref, enum dwarf_attribute,
dw_loc_list_ref);
static void add_data_member_location_attribute (dw_die_ref, tree);
-static bool add_const_value_attribute (dw_die_ref, rtx);
+static bool add_const_value_attribute (dw_die_ref, machine_mode, rtx);
static void insert_int (HOST_WIDE_INT, unsigned, unsigned char *);
static void insert_wide_int (const wide_int &, unsigned char *, int);
static void insert_float (const_rtx, unsigned char *);
@@ -13795,10 +13795,9 @@ loc_descriptor (rtx rtl, machine_mode mode,
break;
case CONST_WIDE_INT:
- if (mode == VOIDmode)
- mode = GET_MODE (rtl);
-
- if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict))
+ if (mode != VOIDmode
+ && mode != BLKmode
+ && (dwarf_version >= 4 || !dwarf_strict))
{
loc_result = new_loc_descr (DW_OP_implicit_value,
GET_MODE_SIZE (mode), 0);
@@ -15576,25 +15575,33 @@ insert_float (const_rtx rtl, unsigned char *array)
constants do not necessarily get memory "homes". */
static bool
-add_const_value_attribute (dw_die_ref die, rtx rtl)
+add_const_value_attribute (dw_die_ref die, machine_mode mode, rtx rtl)
{
switch (GET_CODE (rtl))
{
case CONST_INT:
- {
- HOST_WIDE_INT val = INTVAL (rtl);
+ if (mode != BLKmode)
+ {
+ gcc_checking_assert (SCALAR_INT_MODE_P (mode));
+ HOST_WIDE_INT val = INTVAL (rtl);
- if (val < 0)
- add_AT_int (die, DW_AT_const_value, val);
- else
- add_AT_unsigned (die, DW_AT_const_value, (unsigned HOST_WIDE_INT) val);
- }
- return true;
+ if (val < 0)
+ add_AT_int (die, DW_AT_const_value, val);
+ else
+ add_AT_unsigned (die, DW_AT_const_value,
+ (unsigned HOST_WIDE_INT) val);
+ return true;
+ }
+ return false;
case CONST_WIDE_INT:
- add_AT_wide (die, DW_AT_const_value,
- std::make_pair (rtl, GET_MODE (rtl)));
- return true;
+ if (mode != BLKmode)
+ {
+ gcc_checking_assert (SCALAR_INT_MODE_P (mode));
+ add_AT_wide (die, DW_AT_const_value, std::make_pair (rtl, mode));
+ return true;
+ }
+ return false;
case CONST_DOUBLE:
/* Note that a CONST_DOUBLE rtx could represent either an integer or a
@@ -15671,7 +15678,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
case CONST:
if (CONSTANT_P (XEXP (rtl, 0)))
- return add_const_value_attribute (die, XEXP (rtl, 0));
+ return add_const_value_attribute (die, mode, XEXP (rtl, 0));
/* FALLTHROUGH */
case SYMBOL_REF:
if (!const_ok_for_output (rtl))
@@ -16171,7 +16178,7 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p,
rtl = rtl_for_decl_location (decl);
if (rtl && (CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
- && add_const_value_attribute (die, rtl))
+ && add_const_value_attribute (die, DECL_MODE (decl), rtl))
return true;
/* See if we have single element location list that is equivalent to
@@ -16192,7 +16199,7 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p,
if (GET_CODE (rtl) == EXPR_LIST)
rtl = XEXP (rtl, 0);
if ((CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
- && add_const_value_attribute (die, rtl))
+ && add_const_value_attribute (die, DECL_MODE (decl), rtl))
return true;
}
/* If this decl is from BLOCK_NONLOCALIZED_VARS, we might need its
@@ -16395,7 +16402,7 @@ tree_add_const_value_attribute (dw_die_ref die, tree t)
rtl = rtl_for_decl_init (init, type);
if (rtl)
- return add_const_value_attribute (die, rtl);
+ return add_const_value_attribute (die, TYPE_MODE (type), rtl);
/* If the host and target are sane, try harder. */
else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
&& initializer_constant_valid_p (init, type))
new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { x86_64-*-* && lp64 } } } */
+/* { dg-options "-O -gdwarf -dA" } */
+
+__uint128_t
+test (void)
+{
+ static const __uint128_t foo = ((((__uint128_t) 0x22334455) << 96)
+ | 0x99aabb);
+
+ return foo;
+}
+
+/* { dg-final { scan-assembler {\.quad\t0x99aabb\t# DW_AT_const_value} } } */
+/* { dg-final { scan-assembler {\.quad\t0x2233445500000000\t} } } */