public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046]
@ 2021-11-03  8:35 Jakub Jelinek
  2021-11-03  9:26 ` Jakub Jelinek
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2021-11-03  8:35 UTC (permalink / raw)
  To: Jason Merrill, Richard Biener; +Cc: gcc-patches

Hi!

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.

The following patch fixes that by ensuring the precision is equal to what
we'll actually use, whole multiples of 64 bits.

Bootstrapped/regtested on x86_64-linux and i686-linux.

Though, thinking more about it, maybe better would be to 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.

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

	PR debug/103046
	* dwarf2out.c (add_const_value_attribute) <case CONST_WIDE_INT>: Round
	prec up to next HOST_BITS_PER_WIDE_INT multiple.

--- gcc/dwarf2out.c.jj	2021-10-08 10:52:47.086531820 +0200
+++ gcc/dwarf2out.c	2021-11-02 16:25:24.505504356 +0100
@@ -20102,6 +20102,7 @@ add_const_value_attribute (dw_die_ref di
 	unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED),
 				 (unsigned int) CONST_WIDE_INT_NUNITS (rtl)
 				 * HOST_BITS_PER_WIDE_INT);
+	prec = ROUND_UP (prec, HOST_BITS_PER_WIDE_INT);
 	wide_int w = wide_int::from (w1, prec, UNSIGNED);
 	add_AT_wide (die, DW_AT_const_value, w);
       }

	Jakub


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-03 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  8:35 [PATCH] dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046] Jakub Jelinek
2021-11-03  9:26 ` Jakub Jelinek
2021-11-03 12:59   ` Richard Biener
2021-11-03 13:14     ` Jakub Jelinek
2021-11-03 13:38       ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).