From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15468 invoked by alias); 28 Oct 2015 11:58:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 15452 invoked by uid 89); 28 Oct 2015 11:58:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp15.uk.ibm.com Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 28 Oct 2015 11:58:47 +0000 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Oct 2015 11:58:43 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 28 Oct 2015 11:58:41 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: uweigand@de.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 403CF2190046 for ; Wed, 28 Oct 2015 11:58:38 +0000 (GMT) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9SBwfdX8126858 for ; Wed, 28 Oct 2015 11:58:41 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9SBwe66021932 for ; Wed, 28 Oct 2015 05:58:40 -0600 Received: from oc7340732750.ibm.com (icon-9-164-153-137.megacenter.de.ibm.com [9.164.153.137]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9SBwd0L021914; Wed, 28 Oct 2015 05:58:40 -0600 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id 1E7C85C3D; Wed, 28 Oct 2015 12:58:39 +0100 (CET) Subject: [ping] Re: Fix PR debug/66728 To: richard.sandiford@arm.com (Richard Sandiford) Date: Wed, 28 Oct 2015 12:04:00 -0000 From: "Ulrich Weigand" Cc: gcc-patches@gcc.gnu.org In-Reply-To: <87io88920k.fsf@e105548-lin.cambridge.arm.com> from "Richard Sandiford" at Aug 21, 2015 02:58:35 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20151028115839.1E7C85C3D@oc7340732750.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102811-0021-0000-0000-000007C5B709 X-SW-Source: 2015-10/txt/msg03023.txt.bz2 Hi Richard, seems this still hasn't gone upstream ... Any news? Thanks, Ulrich > This is yet another bug caused by rtx having modeless scalar integer > constants. We need to use context to find the actual mode of a > CONST_INT or CONST_WIDE_INT. > > Getting a mode is especially awkward here. Decls have two modes > associated with them: TYPE_MODE (TREE_TYPE (decl)) and DECL_MODE (decl). > Promotion via things like promote_decl_mode can lead to the rtl having > a mode that is different from both of them. Sometimes structure decls > have BLKmode but are assigned an integer-mode rtl (e.g. when passing > 3-byte structures by value to functions). > > I think in this case we're just going to have to assume that none of > these fancy mode changes happen for something that's big enough to > need a CONST_WIDE_INT. > > loc_descriptor refuses to use CONST_INT for BLKmode decls (which aren't > actually integers at the source level). That seems like the right > behaviour, so this patch does that for add_const_value_attribute too. > It asserts that the mode is otherwise sensible for both CONST_INT > and CONST_WIDE_INT. Asserting for CONST_INT isn't strictly necessary > but means that the assumption will get much more coverage than asserting > only for CONST_WIDE_INT does. > > Tested on x86_64-linux-gnu and aarch64-linux-gnu. Also tested against > the gdb testsuite. OK to install? > > Thanks, > Richard > > gcc/ > PR debug/66728 > * dwarf2out.c (loc_descriptor): Remove redundant GET_MODE of > CONST_WIDE_INTs. Handle BLKmode for CONST_WIDE_INT too. > (add_const_value_attribute): Add a mode parameter. > Check it for CONST_INT and CONST_WIDE_INT. Use it to build > wide_int values. > (add_location_or_const_value_attribute): Update call. > (tree_add_const_value_attribute): Likewise. > > gcc/testsuite/ > PR debug/66728 > * gcc.dg/debug/dwarf2/pr66728.c: New test. > > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c > index d9d3063..383d705 100644 > --- a/gcc/dwarf2out.c > +++ b/gcc/dwarf2out.c > @@ -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; > =20 > case CONST_WIDE_INT: > - if (mode =3D=3D VOIDmode) > - mode =3D GET_MODE (rtl); > - > - if (mode !=3D VOIDmode && (dwarf_version >=3D 4 || !dwarf_strict)) > + if (mode !=3D VOIDmode > + && mode !=3D BLKmode > + && (dwarf_version >=3D 4 || !dwarf_strict)) > { > loc_result =3D 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". */ > =20 > 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 =3D INTVAL (rtl); > + if (mode !=3D BLKmode) > + { > + gcc_checking_assert (SCALAR_INT_MODE_P (mode)); > + HOST_WIDE_INT val =3D INTVAL (rtl); > =20 > - 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; > =20 > case CONST_WIDE_INT: > - add_AT_wide (die, DW_AT_const_value, > - std::make_pair (rtl, GET_MODE (rtl))); > - return true; > + if (mode !=3D 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; > =20 > 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) > =20 > 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 d= > ie, tree decl, bool cache_p, > =20 > rtl =3D rtl_for_decl_location (decl); > if (rtl && (CONSTANT_P (rtl) || GET_CODE (rtl) =3D=3D CONST_STRING) > - && add_const_value_attribute (die, rtl)) > + && add_const_value_attribute (die, DECL_MODE (decl), rtl)) > return true; > =20 > /* 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 d= > ie, tree decl, bool cache_p, > if (GET_CODE (rtl) =3D=3D EXPR_LIST) > rtl =3D XEXP (rtl, 0); > if ((CONSTANT_P (rtl) || GET_CODE (rtl) =3D=3D 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, tre= > e t) > =20 > rtl =3D 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 =3D=3D 8 && BITS_PER_UNIT =3D=3D 8 > && initializer_constant_valid_p (init, type)) > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr66728.c b/gcc/testsuite/gc= > c.dg/debug/dwarf2/pr66728.c > new file mode 100644 > index 0000000..ba41e97 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr66728.c > @@ -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 =3D ((((__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} } } */ > -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com