Jakub Jelinek 155f6b2be4 dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046]
My last change to CONST_WIDE_INT handling in add_const_value_attribute broke
handling of CONST_WIDE_INT constants like ((__uint128_t) 1 << 120).
wi::min_precision (w1, UNSIGNED) in that case 121, but wide_int::from
creates a wide_int that has 0 and 0xff00000000000000ULL in its elts and
precision 121.  When we output that, we output both elements and thus emit
0, 0xff00000000000000 instead of the desired 0, 0x0100000000000000.

IMHO we should actually pass machine_mode to add_const_value_attribute from
callers, so that we know exactly what precision we want.  Because
hypothetically, if say mode is OImode and the CONST_WIDE_INT value fits into
128 bits or 192 bits, we'd emit just those 128 or 192 bits but debug info
users would expect 256 bits.

On
typedef unsigned __int128 U;

int
main ()
{
  U a = (U) 1 << 120;
  U b = 0xffffffffffffffffULL;
  U c = ((U) 0xffffffff00000000ULL) << 64;
  return 0;
}
vanilla gcc incorrectly emits 0, 0xff00000000000000 for a,
0xffffffffffffffff alone (DW_FORM_data8) for b and 0, 0xffffffff00000000
for c.  gcc with the previously posted PR103046 patch emits
0, 0x0100000000000000 for a, 0xffffffffffffffff alone for b and
0, 0xffffffff00000000 for c.  And with this patch we emit
0, 0x0100000000000000 for a, 0xffffffffffffffff, 0 for b and
0, 0xffffffff00000000 for c.
So, the patch below certainly causes larger debug info (well, 128-bit
integers are pretty rare), but in this case the question is if it isn't
more correct, as debug info consumers generally will not know if they
should sign or zero extend the value in DW_AT_const_value.
The previous code assumes they will always zero extend it...

2021-11-05  Jakub Jelinek  <jakub@redhat.com>

	PR debug/103046
	* dwarf2out.c (add_const_value_attribute): Add MODE argument, use it
	in CONST_WIDE_INT handling.  Adjust recursive calls.
	(add_location_or_const_value_attribute): Pass DECL_MODE (decl) to
	new add_const_value_attribute argument.
	(tree_add_const_value_attribute): Pass TYPE_MODE (type) to new
	add_const_value_attribute argument.
2021-11-05 10:20:10 +01:00
2021-10-27 00:16:33 +00:00
2021-09-20 00:16:21 +00:00
2021-11-05 00:16:36 +00:00
2021-10-23 00:16:26 +00:00
2021-09-22 00:16:28 +00:00
2021-09-28 00:16:21 +00:00
2021-10-23 00:16:26 +00:00
2021-10-23 00:16:26 +00:00
2021-11-02 00:16:32 +00:00
2021-11-02 00:16:32 +00:00
2021-10-23 00:16:26 +00:00
2021-11-05 00:16:36 +00:00
2021-10-28 00:16:39 +00:00
2021-10-19 00:16:23 +00:00
2021-10-31 00:16:24 +00:00
2021-10-23 00:16:26 +00:00
2021-10-20 00:16:43 +00:00
2021-11-01 00:16:20 +00:00
2021-11-05 00:16:36 +00:00
2021-11-05 00:16:36 +00:00
2021-11-04 00:16:32 +00:00
2021-10-22 15:43:50 -07:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%