Message ID | 20211103083536.GM304296@tucnak |
---|---|
State | Committed |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E1BA3858D3C for <patchwork@sourceware.org>; Wed, 3 Nov 2021 13:04:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E1BA3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635944649; bh=+HiHhvJYvKzBsq5+B81go2EpI/LtkcywEpzO1voo7Wc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=GEFu3afVM3wYmCovTwJ9zu/d2dhfEWeDZyg8+m7JYONJFargAj7qP/mBsBhfH1uZe SRqgEDwlIaP7LZPWOz+ypSbvyLy8XcVbqBOndHrIbq3gYGzr6+QiA58HU0agavJA9F /IyJ7OVW9r/gjBFMpJDTJ5+S9iSH/sM8tzhVhO6M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 289AF385803F for <gcc-patches@gcc.gnu.org>; Wed, 3 Nov 2021 13:02:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 289AF385803F Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jakub@redhat.com>) id 1miBkM-0008EU-Qt for gcc-patches@gcc.gnu.org; Wed, 03 Nov 2021 04:35:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-559-MhvBAgxLO0qgc7k_USGCww-1; Wed, 03 Nov 2021 04:35:45 -0400 X-MC-Unique: MhvBAgxLO0qgc7k_USGCww-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6819C1966322; Wed, 3 Nov 2021 08:35:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB53B5BAF0; Wed, 3 Nov 2021 08:35:41 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1A38Zcqc2282474 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 3 Nov 2021 09:35:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1A38ZaBG2282471; Wed, 3 Nov 2021 09:35:36 +0100 Date: Wed, 3 Nov 2021 09:35:36 +0100 To: Jason Merrill <jason@redhat.com>, Richard Biener <rguenther@suse.de> Subject: [PATCH] dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046] Message-ID: <20211103083536.GM304296@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=jakub@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.702, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
dwarf2out: Fix up CONST_WIDE_INT handling once more [PR103046]
|
|
Commit Message
Jakub Jelinek
Nov. 3, 2021, 8:35 a.m. UTC
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. Jakub
Comments
On Wed, Nov 03, 2021 at 09:35:38AM +0100, Jakub Jelinek wrote: > 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. The other option would be something like untested patch below. 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-03 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. --- gcc/dwarf2out.c.jj 2021-10-08 10:52:47.086531820 +0200 +++ gcc/dwarf2out.c 2021-11-03 09:45:52.160841764 +0100 @@ -3854,7 +3854,7 @@ static void add_AT_location_description dw_loc_list_ref); static void add_data_member_location_attribute (dw_die_ref, tree, struct vlr_context *); -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 unsigned insert_float (const_rtx, unsigned char *); @@ -20081,8 +20081,10 @@ insert_float (const_rtx rtl, unsigned ch 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) { + scalar_mode int_mode; + switch (GET_CODE (rtl)) { case CONST_INT: @@ -20097,14 +20099,13 @@ add_const_value_attribute (dw_die_ref di return true; case CONST_WIDE_INT: - { - wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT); - unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED), - (unsigned int) CONST_WIDE_INT_NUNITS (rtl) - * HOST_BITS_PER_WIDE_INT); - wide_int w = wide_int::from (w1, prec, UNSIGNED); - add_AT_wide (die, DW_AT_const_value, w); - } + if (is_int_mode (mode, &int_mode) + && (GET_MODE_PRECISION (int_mode) + & (HOST_BITS_PER_WIDE_INT - 1)) == 0) + { + wide_int w = rtx_mode_t (rtl, int_mode); + add_AT_wide (die, DW_AT_const_value, w); + } return true; case CONST_DOUBLE: @@ -20190,7 +20191,7 @@ add_const_value_attribute (dw_die_ref di 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)) @@ -20703,7 +20704,7 @@ add_location_or_const_value_attribute (d 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 @@ -20724,7 +20725,7 @@ add_location_or_const_value_attribute (d 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 @@ -20799,7 +20800,7 @@ tree_add_const_value_attribute (dw_die_r symbols. */ rtl = rtl_for_decl_init (init, type); if (rtl && !early_dwarf) - 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. */ if (CHAR_BIT == 8 && BITS_PER_UNIT == 8 && initializer_constant_valid_p (init, type)) Jakub
On Wed, Nov 03, 2021 at 01:59:27PM +0100, Richard Biener wrote: > > case CONST_WIDE_INT: > > - { > > - wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT); > > - unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED), > > - (unsigned int) CONST_WIDE_INT_NUNITS (rtl) > > - * HOST_BITS_PER_WIDE_INT); > > - wide_int w = wide_int::from (w1, prec, UNSIGNED); > > - add_AT_wide (die, DW_AT_const_value, w); > > - } > > + if (is_int_mode (mode, &int_mode) > > + && (GET_MODE_PRECISION (int_mode) > > + & (HOST_BITS_PER_WIDE_INT - 1)) == 0) > > + { > > + wide_int w = rtx_mode_t (rtl, int_mode); > > + add_AT_wide (die, DW_AT_const_value, w); > > + } > > ... this at least deserves a comment why we return true doing > nothing when the mode precision isn't a multiple of 64. The other > patch simply extended things. Oops, that is obviously a bug. For non-integral mode or mode with precision not a multiple of 64 I meant to punt. The reason for the latter is that if precision is something weird like 123 bits, then the printing code will print the whole 64-bit elt which would be wrong for at least unsigned numbers with MSB set. I guess such modes are still very rare to non-existing. 2021-11-03 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. --- gcc/dwarf2out.c.jj 2021-10-08 10:52:47.086531820 +0200 +++ gcc/dwarf2out.c 2021-11-03 14:06:22.750387774 +0100 @@ -3854,7 +3854,7 @@ static void add_AT_location_description dw_loc_list_ref); static void add_data_member_location_attribute (dw_die_ref, tree, struct vlr_context *); -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 unsigned insert_float (const_rtx, unsigned char *); @@ -20081,8 +20081,10 @@ insert_float (const_rtx rtl, unsigned ch 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) { + scalar_mode int_mode; + switch (GET_CODE (rtl)) { case CONST_INT: @@ -20097,15 +20099,15 @@ add_const_value_attribute (dw_die_ref di return true; case CONST_WIDE_INT: - { - wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT); - unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED), - (unsigned int) CONST_WIDE_INT_NUNITS (rtl) - * HOST_BITS_PER_WIDE_INT); - wide_int w = wide_int::from (w1, prec, UNSIGNED); - add_AT_wide (die, DW_AT_const_value, w); - } - return true; + if (is_int_mode (mode, &int_mode) + && (GET_MODE_PRECISION (int_mode) + & (HOST_BITS_PER_WIDE_INT - 1)) == 0) + { + wide_int w = rtx_mode_t (rtl, int_mode); + add_AT_wide (die, DW_AT_const_value, w); + return true; + } + return false; case CONST_DOUBLE: /* Note that a CONST_DOUBLE rtx could represent either an integer or a @@ -20190,7 +20192,7 @@ add_const_value_attribute (dw_die_ref di 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)) @@ -20703,7 +20705,7 @@ add_location_or_const_value_attribute (d 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 @@ -20724,7 +20726,7 @@ add_location_or_const_value_attribute (d 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 @@ -20799,7 +20801,7 @@ tree_add_const_value_attribute (dw_die_r symbols. */ rtl = rtl_for_decl_init (init, type); if (rtl && !early_dwarf) - 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. */ if (CHAR_BIT == 8 && BITS_PER_UNIT == 8 && initializer_constant_valid_p (init, type)) Jakub
On Wed, 3 Nov 2021, Jakub Jelinek wrote: > On Wed, Nov 03, 2021 at 01:59:27PM +0100, Richard Biener wrote: > > > case CONST_WIDE_INT: > > > - { > > > - wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT); > > > - unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED), > > > - (unsigned int) CONST_WIDE_INT_NUNITS (rtl) > > > - * HOST_BITS_PER_WIDE_INT); > > > - wide_int w = wide_int::from (w1, prec, UNSIGNED); > > > - add_AT_wide (die, DW_AT_const_value, w); > > > - } > > > + if (is_int_mode (mode, &int_mode) > > > + && (GET_MODE_PRECISION (int_mode) > > > + & (HOST_BITS_PER_WIDE_INT - 1)) == 0) > > > + { > > > + wide_int w = rtx_mode_t (rtl, int_mode); > > > + add_AT_wide (die, DW_AT_const_value, w); > > > + } > > > > ... this at least deserves a comment why we return true doing > > nothing when the mode precision isn't a multiple of 64. The other > > patch simply extended things. > > Oops, that is obviously a bug. For non-integral mode or mode with > precision not a multiple of 64 I meant to punt. The reason for the latter > is that if precision is something weird like 123 bits, then the printing > code will print the whole 64-bit elt which would be wrong for at least > unsigned numbers with MSB set. I guess such modes are still very rare to > non-existing. Agreed. The patch looks good to me now. Thanks, Richard. > 2021-11-03 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. > > --- gcc/dwarf2out.c.jj 2021-10-08 10:52:47.086531820 +0200 > +++ gcc/dwarf2out.c 2021-11-03 14:06:22.750387774 +0100 > @@ -3854,7 +3854,7 @@ static void add_AT_location_description > dw_loc_list_ref); > static void add_data_member_location_attribute (dw_die_ref, tree, > struct vlr_context *); > -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 unsigned insert_float (const_rtx, unsigned char *); > @@ -20081,8 +20081,10 @@ insert_float (const_rtx rtl, unsigned ch > 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) > { > + scalar_mode int_mode; > + > switch (GET_CODE (rtl)) > { > case CONST_INT: > @@ -20097,15 +20099,15 @@ add_const_value_attribute (dw_die_ref di > return true; > > case CONST_WIDE_INT: > - { > - wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT); > - unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED), > - (unsigned int) CONST_WIDE_INT_NUNITS (rtl) > - * HOST_BITS_PER_WIDE_INT); > - wide_int w = wide_int::from (w1, prec, UNSIGNED); > - add_AT_wide (die, DW_AT_const_value, w); > - } > - return true; > + if (is_int_mode (mode, &int_mode) > + && (GET_MODE_PRECISION (int_mode) > + & (HOST_BITS_PER_WIDE_INT - 1)) == 0) > + { > + wide_int w = rtx_mode_t (rtl, int_mode); > + add_AT_wide (die, DW_AT_const_value, w); > + return true; > + } > + return false; > > case CONST_DOUBLE: > /* Note that a CONST_DOUBLE rtx could represent either an integer or a > @@ -20190,7 +20192,7 @@ add_const_value_attribute (dw_die_ref di > > 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)) > @@ -20703,7 +20705,7 @@ add_location_or_const_value_attribute (d > > 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 > @@ -20724,7 +20726,7 @@ add_location_or_const_value_attribute (d > 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 > @@ -20799,7 +20801,7 @@ tree_add_const_value_attribute (dw_die_r > symbols. */ > rtl = rtl_for_decl_init (init, type); > if (rtl && !early_dwarf) > - 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. */ > if (CHAR_BIT == 8 && BITS_PER_UNIT == 8 > && initializer_constant_valid_p (init, type)) > > > Jakub > >
--- 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); }